김가영

batch file update

Showing 394 changed files with 3861 additions and 0 deletions
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
1 +@echo
2 +cd C:\Users\rkdud\Desktop\batch_file
3 +adb devices > C:\Users\rkdud\Desktop\batch_file\device.csv
4 +adb shell dumpsys alarm > C:\Users\rkdud\Desktop\batch_file\alarm.csv
5 +adb shell ps -A > C:\Users\rkdud\Desktop\batch_file\process.csv
6 +adb shell uptime > C:\Users\rkdud\Desktop\batch_file\uptime.csv
7 +adb shell getprop ro.product.model > C:\Users\rkdud\Desktop\batch_file\model.csv
8 +adb shell getprop ro.build.version.release > C:\Users\rkdud\Desktop\batch_file\sdk_version.csv
9 +adb shell getprop ro.build.version.sdk > C:\Users\rkdud\Desktop\batch_file\android_version.csv
10 +adb install -r app-release.apk
11 +start cmd.exe /k "node data.js"
12 +adb shell am start -n com.example.dataextraction/com.example.dataextraction.LoadingActivity
13 +@echo please execute the app
14 +pause
...\ No newline at end of file ...\ No newline at end of file
No preview for this file type
1 +const path = require('path')
2 +const fs = require('fs')
3 +var io = require('socket.io').listen(3000);
4 +var exec = require('child_process').exec, child;
5 +//var mysql = require('mysql');
6 +
7 +
8 +//3. adb backup 명령어를 통해 데이터베이스 추출
9 +function extractDB () {
10 + cmd_backup = exec('adb backup com.example.dataextraction -f backup.dataextraction.ad', function(error, stdout, stderr){
11 + console.log("backup app");
12 + setTimeout(function(){
13 + cmd_unpack = exec('java -jar abe.jar unpack backup.dataextraction.ad dataextraction.tar',function(error, stdout, stderr){
14 + console.log("unpack backup");
15 + cmd_unzip = exec('tar xvf dataextraction.tar', function(error, stdout, stderr){
16 + console.log("unzip tar");
17 + cmd_moveIdb = fs.rename('apps/com.example.dataextraction/db/InnerDatabase.db', 'InnerDatabase.db', function(){
18 + console.log("move innerDB");
19 + cmd_moveNdb = fs.rename('apps/com.example.dataextraction/db/networkDatabase.db', 'networkDatabase.db',function(){
20 + console.log("move network db");
21 + })
22 + })
23 + })
24 + })
25 + },7000);
26 + });
27 +}
28 +
29 +//2. 애플리케이션에서 데이터베이스 생성이 끝나면 알림
30 +io.on('connection', function(socket){
31 + var instanceId = socket.id;
32 +
33 + socket.on('alert', function(data){
34 + console.log("alert");
35 + })
36 + socket.on('end', function(data){
37 + console.log("extract db end");
38 + extractDB();
39 + })
40 +})
...\ No newline at end of file ...\ No newline at end of file
1 +1.3.7 / 2019-04-29
2 +==================
3 +
4 + * deps: negotiator@0.6.2
5 + - Fix sorting charset, encoding, and language with extra parameters
6 +
7 +1.3.6 / 2019-04-28
8 +==================
9 +
10 + * deps: mime-types@~2.1.24
11 + - deps: mime-db@~1.40.0
12 +
13 +1.3.5 / 2018-02-28
14 +==================
15 +
16 + * deps: mime-types@~2.1.18
17 + - deps: mime-db@~1.33.0
18 +
19 +1.3.4 / 2017-08-22
20 +==================
21 +
22 + * deps: mime-types@~2.1.16
23 + - deps: mime-db@~1.29.0
24 +
25 +1.3.3 / 2016-05-02
26 +==================
27 +
28 + * deps: mime-types@~2.1.11
29 + - deps: mime-db@~1.23.0
30 + * deps: negotiator@0.6.1
31 + - perf: improve `Accept` parsing speed
32 + - perf: improve `Accept-Charset` parsing speed
33 + - perf: improve `Accept-Encoding` parsing speed
34 + - perf: improve `Accept-Language` parsing speed
35 +
36 +1.3.2 / 2016-03-08
37 +==================
38 +
39 + * deps: mime-types@~2.1.10
40 + - Fix extension of `application/dash+xml`
41 + - Update primary extension for `audio/mp4`
42 + - deps: mime-db@~1.22.0
43 +
44 +1.3.1 / 2016-01-19
45 +==================
46 +
47 + * deps: mime-types@~2.1.9
48 + - deps: mime-db@~1.21.0
49 +
50 +1.3.0 / 2015-09-29
51 +==================
52 +
53 + * deps: mime-types@~2.1.7
54 + - deps: mime-db@~1.19.0
55 + * deps: negotiator@0.6.0
56 + - Fix including type extensions in parameters in `Accept` parsing
57 + - Fix parsing `Accept` parameters with quoted equals
58 + - Fix parsing `Accept` parameters with quoted semicolons
59 + - Lazy-load modules from main entry point
60 + - perf: delay type concatenation until needed
61 + - perf: enable strict mode
62 + - perf: hoist regular expressions
63 + - perf: remove closures getting spec properties
64 + - perf: remove a closure from media type parsing
65 + - perf: remove property delete from media type parsing
66 +
67 +1.2.13 / 2015-09-06
68 +===================
69 +
70 + * deps: mime-types@~2.1.6
71 + - deps: mime-db@~1.18.0
72 +
73 +1.2.12 / 2015-07-30
74 +===================
75 +
76 + * deps: mime-types@~2.1.4
77 + - deps: mime-db@~1.16.0
78 +
79 +1.2.11 / 2015-07-16
80 +===================
81 +
82 + * deps: mime-types@~2.1.3
83 + - deps: mime-db@~1.15.0
84 +
85 +1.2.10 / 2015-07-01
86 +===================
87 +
88 + * deps: mime-types@~2.1.2
89 + - deps: mime-db@~1.14.0
90 +
91 +1.2.9 / 2015-06-08
92 +==================
93 +
94 + * deps: mime-types@~2.1.1
95 + - perf: fix deopt during mapping
96 +
97 +1.2.8 / 2015-06-07
98 +==================
99 +
100 + * deps: mime-types@~2.1.0
101 + - deps: mime-db@~1.13.0
102 + * perf: avoid argument reassignment & argument slice
103 + * perf: avoid negotiator recursive construction
104 + * perf: enable strict mode
105 + * perf: remove unnecessary bitwise operator
106 +
107 +1.2.7 / 2015-05-10
108 +==================
109 +
110 + * deps: negotiator@0.5.3
111 + - Fix media type parameter matching to be case-insensitive
112 +
113 +1.2.6 / 2015-05-07
114 +==================
115 +
116 + * deps: mime-types@~2.0.11
117 + - deps: mime-db@~1.9.1
118 + * deps: negotiator@0.5.2
119 + - Fix comparing media types with quoted values
120 + - Fix splitting media types with quoted commas
121 +
122 +1.2.5 / 2015-03-13
123 +==================
124 +
125 + * deps: mime-types@~2.0.10
126 + - deps: mime-db@~1.8.0
127 +
128 +1.2.4 / 2015-02-14
129 +==================
130 +
131 + * Support Node.js 0.6
132 + * deps: mime-types@~2.0.9
133 + - deps: mime-db@~1.7.0
134 + * deps: negotiator@0.5.1
135 + - Fix preference sorting to be stable for long acceptable lists
136 +
137 +1.2.3 / 2015-01-31
138 +==================
139 +
140 + * deps: mime-types@~2.0.8
141 + - deps: mime-db@~1.6.0
142 +
143 +1.2.2 / 2014-12-30
144 +==================
145 +
146 + * deps: mime-types@~2.0.7
147 + - deps: mime-db@~1.5.0
148 +
149 +1.2.1 / 2014-12-30
150 +==================
151 +
152 + * deps: mime-types@~2.0.5
153 + - deps: mime-db@~1.3.1
154 +
155 +1.2.0 / 2014-12-19
156 +==================
157 +
158 + * deps: negotiator@0.5.0
159 + - Fix list return order when large accepted list
160 + - Fix missing identity encoding when q=0 exists
161 + - Remove dynamic building of Negotiator class
162 +
163 +1.1.4 / 2014-12-10
164 +==================
165 +
166 + * deps: mime-types@~2.0.4
167 + - deps: mime-db@~1.3.0
168 +
169 +1.1.3 / 2014-11-09
170 +==================
171 +
172 + * deps: mime-types@~2.0.3
173 + - deps: mime-db@~1.2.0
174 +
175 +1.1.2 / 2014-10-14
176 +==================
177 +
178 + * deps: negotiator@0.4.9
179 + - Fix error when media type has invalid parameter
180 +
181 +1.1.1 / 2014-09-28
182 +==================
183 +
184 + * deps: mime-types@~2.0.2
185 + - deps: mime-db@~1.1.0
186 + * deps: negotiator@0.4.8
187 + - Fix all negotiations to be case-insensitive
188 + - Stable sort preferences of same quality according to client order
189 +
190 +1.1.0 / 2014-09-02
191 +==================
192 +
193 + * update `mime-types`
194 +
195 +1.0.7 / 2014-07-04
196 +==================
197 +
198 + * Fix wrong type returned from `type` when match after unknown extension
199 +
200 +1.0.6 / 2014-06-24
201 +==================
202 +
203 + * deps: negotiator@0.4.7
204 +
205 +1.0.5 / 2014-06-20
206 +==================
207 +
208 + * fix crash when unknown extension given
209 +
210 +1.0.4 / 2014-06-19
211 +==================
212 +
213 + * use `mime-types`
214 +
215 +1.0.3 / 2014-06-11
216 +==================
217 +
218 + * deps: negotiator@0.4.6
219 + - Order by specificity when quality is the same
220 +
221 +1.0.2 / 2014-05-29
222 +==================
223 +
224 + * Fix interpretation when header not in request
225 + * deps: pin negotiator@0.4.5
226 +
227 +1.0.1 / 2014-01-18
228 +==================
229 +
230 + * Identity encoding isn't always acceptable
231 + * deps: negotiator@~0.4.0
232 +
233 +1.0.0 / 2013-12-27
234 +==================
235 +
236 + * Genesis
1 +(The MIT License)
2 +
3 +Copyright (c) 2014 Jonathan Ong <me@jongleberry.com>
4 +Copyright (c) 2015 Douglas Christopher Wilson <doug@somethingdoug.com>
5 +
6 +Permission is hereby granted, free of charge, to any person obtaining
7 +a copy of this software and associated documentation files (the
8 +'Software'), to deal in the Software without restriction, including
9 +without limitation the rights to use, copy, modify, merge, publish,
10 +distribute, sublicense, and/or sell copies of the Software, and to
11 +permit persons to whom the Software is furnished to do so, subject to
12 +the following conditions:
13 +
14 +The above copyright notice and this permission notice shall be
15 +included in all copies or substantial portions of the Software.
16 +
17 +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
18 +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1 +# accepts
2 +
3 +[![NPM Version][npm-version-image]][npm-url]
4 +[![NPM Downloads][npm-downloads-image]][npm-url]
5 +[![Node.js Version][node-version-image]][node-version-url]
6 +[![Build Status][travis-image]][travis-url]
7 +[![Test Coverage][coveralls-image]][coveralls-url]
8 +
9 +Higher level content negotiation based on [negotiator](https://www.npmjs.com/package/negotiator).
10 +Extracted from [koa](https://www.npmjs.com/package/koa) for general use.
11 +
12 +In addition to negotiator, it allows:
13 +
14 +- Allows types as an array or arguments list, ie `(['text/html', 'application/json'])`
15 + as well as `('text/html', 'application/json')`.
16 +- Allows type shorthands such as `json`.
17 +- Returns `false` when no types match
18 +- Treats non-existent headers as `*`
19 +
20 +## Installation
21 +
22 +This is a [Node.js](https://nodejs.org/en/) module available through the
23 +[npm registry](https://www.npmjs.com/). Installation is done using the
24 +[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):
25 +
26 +```sh
27 +$ npm install accepts
28 +```
29 +
30 +## API
31 +
32 +<!-- eslint-disable no-unused-vars -->
33 +
34 +```js
35 +var accepts = require('accepts')
36 +```
37 +
38 +### accepts(req)
39 +
40 +Create a new `Accepts` object for the given `req`.
41 +
42 +#### .charset(charsets)
43 +
44 +Return the first accepted charset. If nothing in `charsets` is accepted,
45 +then `false` is returned.
46 +
47 +#### .charsets()
48 +
49 +Return the charsets that the request accepts, in the order of the client's
50 +preference (most preferred first).
51 +
52 +#### .encoding(encodings)
53 +
54 +Return the first accepted encoding. If nothing in `encodings` is accepted,
55 +then `false` is returned.
56 +
57 +#### .encodings()
58 +
59 +Return the encodings that the request accepts, in the order of the client's
60 +preference (most preferred first).
61 +
62 +#### .language(languages)
63 +
64 +Return the first accepted language. If nothing in `languages` is accepted,
65 +then `false` is returned.
66 +
67 +#### .languages()
68 +
69 +Return the languages that the request accepts, in the order of the client's
70 +preference (most preferred first).
71 +
72 +#### .type(types)
73 +
74 +Return the first accepted type (and it is returned as the same text as what
75 +appears in the `types` array). If nothing in `types` is accepted, then `false`
76 +is returned.
77 +
78 +The `types` array can contain full MIME types or file extensions. Any value
79 +that is not a full MIME types is passed to `require('mime-types').lookup`.
80 +
81 +#### .types()
82 +
83 +Return the types that the request accepts, in the order of the client's
84 +preference (most preferred first).
85 +
86 +## Examples
87 +
88 +### Simple type negotiation
89 +
90 +This simple example shows how to use `accepts` to return a different typed
91 +respond body based on what the client wants to accept. The server lists it's
92 +preferences in order and will get back the best match between the client and
93 +server.
94 +
95 +```js
96 +var accepts = require('accepts')
97 +var http = require('http')
98 +
99 +function app (req, res) {
100 + var accept = accepts(req)
101 +
102 + // the order of this list is significant; should be server preferred order
103 + switch (accept.type(['json', 'html'])) {
104 + case 'json':
105 + res.setHeader('Content-Type', 'application/json')
106 + res.write('{"hello":"world!"}')
107 + break
108 + case 'html':
109 + res.setHeader('Content-Type', 'text/html')
110 + res.write('<b>hello, world!</b>')
111 + break
112 + default:
113 + // the fallback is text/plain, so no need to specify it above
114 + res.setHeader('Content-Type', 'text/plain')
115 + res.write('hello, world!')
116 + break
117 + }
118 +
119 + res.end()
120 +}
121 +
122 +http.createServer(app).listen(3000)
123 +```
124 +
125 +You can test this out with the cURL program:
126 +```sh
127 +curl -I -H'Accept: text/html' http://localhost:3000/
128 +```
129 +
130 +## License
131 +
132 +[MIT](LICENSE)
133 +
134 +[coveralls-image]: https://badgen.net/coveralls/c/github/jshttp/accepts/master
135 +[coveralls-url]: https://coveralls.io/r/jshttp/accepts?branch=master
136 +[node-version-image]: https://badgen.net/npm/node/accepts
137 +[node-version-url]: https://nodejs.org/en/download
138 +[npm-downloads-image]: https://badgen.net/npm/dm/accepts
139 +[npm-url]: https://npmjs.org/package/accepts
140 +[npm-version-image]: https://badgen.net/npm/v/accepts
141 +[travis-image]: https://badgen.net/travis/jshttp/accepts/master
142 +[travis-url]: https://travis-ci.org/jshttp/accepts
1 +/*!
2 + * accepts
3 + * Copyright(c) 2014 Jonathan Ong
4 + * Copyright(c) 2015 Douglas Christopher Wilson
5 + * MIT Licensed
6 + */
7 +
8 +'use strict'
9 +
10 +/**
11 + * Module dependencies.
12 + * @private
13 + */
14 +
15 +var Negotiator = require('negotiator')
16 +var mime = require('mime-types')
17 +
18 +/**
19 + * Module exports.
20 + * @public
21 + */
22 +
23 +module.exports = Accepts
24 +
25 +/**
26 + * Create a new Accepts object for the given req.
27 + *
28 + * @param {object} req
29 + * @public
30 + */
31 +
32 +function Accepts (req) {
33 + if (!(this instanceof Accepts)) {
34 + return new Accepts(req)
35 + }
36 +
37 + this.headers = req.headers
38 + this.negotiator = new Negotiator(req)
39 +}
40 +
41 +/**
42 + * Check if the given `type(s)` is acceptable, returning
43 + * the best match when true, otherwise `undefined`, in which
44 + * case you should respond with 406 "Not Acceptable".
45 + *
46 + * The `type` value may be a single mime type string
47 + * such as "application/json", the extension name
48 + * such as "json" or an array `["json", "html", "text/plain"]`. When a list
49 + * or array is given the _best_ match, if any is returned.
50 + *
51 + * Examples:
52 + *
53 + * // Accept: text/html
54 + * this.types('html');
55 + * // => "html"
56 + *
57 + * // Accept: text/*, application/json
58 + * this.types('html');
59 + * // => "html"
60 + * this.types('text/html');
61 + * // => "text/html"
62 + * this.types('json', 'text');
63 + * // => "json"
64 + * this.types('application/json');
65 + * // => "application/json"
66 + *
67 + * // Accept: text/*, application/json
68 + * this.types('image/png');
69 + * this.types('png');
70 + * // => undefined
71 + *
72 + * // Accept: text/*;q=.5, application/json
73 + * this.types(['html', 'json']);
74 + * this.types('html', 'json');
75 + * // => "json"
76 + *
77 + * @param {String|Array} types...
78 + * @return {String|Array|Boolean}
79 + * @public
80 + */
81 +
82 +Accepts.prototype.type =
83 +Accepts.prototype.types = function (types_) {
84 + var types = types_
85 +
86 + // support flattened arguments
87 + if (types && !Array.isArray(types)) {
88 + types = new Array(arguments.length)
89 + for (var i = 0; i < types.length; i++) {
90 + types[i] = arguments[i]
91 + }
92 + }
93 +
94 + // no types, return all requested types
95 + if (!types || types.length === 0) {
96 + return this.negotiator.mediaTypes()
97 + }
98 +
99 + // no accept header, return first given type
100 + if (!this.headers.accept) {
101 + return types[0]
102 + }
103 +
104 + var mimes = types.map(extToMime)
105 + var accepts = this.negotiator.mediaTypes(mimes.filter(validMime))
106 + var first = accepts[0]
107 +
108 + return first
109 + ? types[mimes.indexOf(first)]
110 + : false
111 +}
112 +
113 +/**
114 + * Return accepted encodings or best fit based on `encodings`.
115 + *
116 + * Given `Accept-Encoding: gzip, deflate`
117 + * an array sorted by quality is returned:
118 + *
119 + * ['gzip', 'deflate']
120 + *
121 + * @param {String|Array} encodings...
122 + * @return {String|Array}
123 + * @public
124 + */
125 +
126 +Accepts.prototype.encoding =
127 +Accepts.prototype.encodings = function (encodings_) {
128 + var encodings = encodings_
129 +
130 + // support flattened arguments
131 + if (encodings && !Array.isArray(encodings)) {
132 + encodings = new Array(arguments.length)
133 + for (var i = 0; i < encodings.length; i++) {
134 + encodings[i] = arguments[i]
135 + }
136 + }
137 +
138 + // no encodings, return all requested encodings
139 + if (!encodings || encodings.length === 0) {
140 + return this.negotiator.encodings()
141 + }
142 +
143 + return this.negotiator.encodings(encodings)[0] || false
144 +}
145 +
146 +/**
147 + * Return accepted charsets or best fit based on `charsets`.
148 + *
149 + * Given `Accept-Charset: utf-8, iso-8859-1;q=0.2, utf-7;q=0.5`
150 + * an array sorted by quality is returned:
151 + *
152 + * ['utf-8', 'utf-7', 'iso-8859-1']
153 + *
154 + * @param {String|Array} charsets...
155 + * @return {String|Array}
156 + * @public
157 + */
158 +
159 +Accepts.prototype.charset =
160 +Accepts.prototype.charsets = function (charsets_) {
161 + var charsets = charsets_
162 +
163 + // support flattened arguments
164 + if (charsets && !Array.isArray(charsets)) {
165 + charsets = new Array(arguments.length)
166 + for (var i = 0; i < charsets.length; i++) {
167 + charsets[i] = arguments[i]
168 + }
169 + }
170 +
171 + // no charsets, return all requested charsets
172 + if (!charsets || charsets.length === 0) {
173 + return this.negotiator.charsets()
174 + }
175 +
176 + return this.negotiator.charsets(charsets)[0] || false
177 +}
178 +
179 +/**
180 + * Return accepted languages or best fit based on `langs`.
181 + *
182 + * Given `Accept-Language: en;q=0.8, es, pt`
183 + * an array sorted by quality is returned:
184 + *
185 + * ['es', 'pt', 'en']
186 + *
187 + * @param {String|Array} langs...
188 + * @return {Array|String}
189 + * @public
190 + */
191 +
192 +Accepts.prototype.lang =
193 +Accepts.prototype.langs =
194 +Accepts.prototype.language =
195 +Accepts.prototype.languages = function (languages_) {
196 + var languages = languages_
197 +
198 + // support flattened arguments
199 + if (languages && !Array.isArray(languages)) {
200 + languages = new Array(arguments.length)
201 + for (var i = 0; i < languages.length; i++) {
202 + languages[i] = arguments[i]
203 + }
204 + }
205 +
206 + // no languages, return all requested languages
207 + if (!languages || languages.length === 0) {
208 + return this.negotiator.languages()
209 + }
210 +
211 + return this.negotiator.languages(languages)[0] || false
212 +}
213 +
214 +/**
215 + * Convert extnames to mime.
216 + *
217 + * @param {String} type
218 + * @return {String}
219 + * @private
220 + */
221 +
222 +function extToMime (type) {
223 + return type.indexOf('/') === -1
224 + ? mime.lookup(type)
225 + : type
226 +}
227 +
228 +/**
229 + * Check if mime is valid.
230 + *
231 + * @param {String} type
232 + * @return {String}
233 + * @private
234 + */
235 +
236 +function validMime (type) {
237 + return typeof type === 'string'
238 +}
1 +{
2 + "_from": "accepts@~1.3.4",
3 + "_id": "accepts@1.3.7",
4 + "_inBundle": false,
5 + "_integrity": "sha512-Il80Qs2WjYlJIBNzNkK6KYqlVMTbZLXgHx2oT0pU/fjRHyEp+PEfEPY0R3WCwAGVOtauxh1hOxNgIf5bv7dQpA==",
6 + "_location": "/accepts",
7 + "_phantomChildren": {},
8 + "_requested": {
9 + "type": "range",
10 + "registry": true,
11 + "raw": "accepts@~1.3.4",
12 + "name": "accepts",
13 + "escapedName": "accepts",
14 + "rawSpec": "~1.3.4",
15 + "saveSpec": null,
16 + "fetchSpec": "~1.3.4"
17 + },
18 + "_requiredBy": [
19 + "/engine.io"
20 + ],
21 + "_resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.7.tgz",
22 + "_shasum": "531bc726517a3b2b41f850021c6cc15eaab507cd",
23 + "_spec": "accepts@~1.3.4",
24 + "_where": "C:\\Users\\rkdud\\Desktop\\batch_file\\node_modules\\engine.io",
25 + "bugs": {
26 + "url": "https://github.com/jshttp/accepts/issues"
27 + },
28 + "bundleDependencies": false,
29 + "contributors": [
30 + {
31 + "name": "Douglas Christopher Wilson",
32 + "email": "doug@somethingdoug.com"
33 + },
34 + {
35 + "name": "Jonathan Ong",
36 + "email": "me@jongleberry.com",
37 + "url": "http://jongleberry.com"
38 + }
39 + ],
40 + "dependencies": {
41 + "mime-types": "~2.1.24",
42 + "negotiator": "0.6.2"
43 + },
44 + "deprecated": false,
45 + "description": "Higher-level content negotiation",
46 + "devDependencies": {
47 + "deep-equal": "1.0.1",
48 + "eslint": "5.16.0",
49 + "eslint-config-standard": "12.0.0",
50 + "eslint-plugin-import": "2.17.2",
51 + "eslint-plugin-markdown": "1.0.0",
52 + "eslint-plugin-node": "8.0.1",
53 + "eslint-plugin-promise": "4.1.1",
54 + "eslint-plugin-standard": "4.0.0",
55 + "mocha": "6.1.4",
56 + "nyc": "14.0.0"
57 + },
58 + "engines": {
59 + "node": ">= 0.6"
60 + },
61 + "files": [
62 + "LICENSE",
63 + "HISTORY.md",
64 + "index.js"
65 + ],
66 + "homepage": "https://github.com/jshttp/accepts#readme",
67 + "keywords": [
68 + "content",
69 + "negotiation",
70 + "accept",
71 + "accepts"
72 + ],
73 + "license": "MIT",
74 + "name": "accepts",
75 + "repository": {
76 + "type": "git",
77 + "url": "git+https://github.com/jshttp/accepts.git"
78 + },
79 + "scripts": {
80 + "lint": "eslint --plugin markdown --ext js,md .",
81 + "test": "mocha --reporter spec --check-leaks --bail test/",
82 + "test-cov": "nyc --reporter=html --reporter=text npm test",
83 + "test-travis": "nyc --reporter=text npm test"
84 + },
85 + "version": "1.3.7"
86 +}
1 +language: node_js
2 +node_js:
3 + - 0.6
4 + - 0.8
5 + - 0.9
6 + - 0.10
7 + - 0.12
8 + - 4.2.4
9 + - 5.4.1
10 + - iojs-1
11 + - iojs-2
12 + - iojs-3
1 +Copyright (c) 2011 Raynos.
2 +
3 +Permission is hereby granted, free of charge, to any person obtaining a copy
4 +of this software and associated documentation files (the "Software"), to deal
5 +in the Software without restriction, including without limitation the rights
6 +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 +copies of the Software, and to permit persons to whom the Software is
8 +furnished to do so, subject to the following conditions:
9 +
10 +The above copyright notice and this permission notice shall be included in
11 +all copies or substantial portions of the Software.
12 +
13 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 +THE SOFTWARE.
...\ No newline at end of file ...\ No newline at end of file
1 +# After [![Build Status][1]][2]
2 +
3 +Invoke callback after n calls
4 +
5 +## Status: production ready
6 +
7 +## Example
8 +
9 +```js
10 +var after = require("after")
11 +var db = require("./db") // some db.
12 +
13 +var updateUser = function (req, res) {
14 + // use after to run two tasks in parallel,
15 + // namely get request body and get session
16 + // then run updateUser with the results
17 + var next = after(2, updateUser)
18 + var results = {}
19 +
20 + getJSONBody(req, res, function (err, body) {
21 + if (err) return next(err)
22 +
23 + results.body = body
24 + next(null, results)
25 + })
26 +
27 + getSessionUser(req, res, function (err, user) {
28 + if (err) return next(err)
29 +
30 + results.user = user
31 + next(null, results)
32 + })
33 +
34 + // now do the thing!
35 + function updateUser(err, result) {
36 + if (err) {
37 + res.statusCode = 500
38 + return res.end("Unexpected Error")
39 + }
40 +
41 + if (!result.user || result.user.role !== "admin") {
42 + res.statusCode = 403
43 + return res.end("Permission Denied")
44 + }
45 +
46 + db.put("users:" + req.params.userId, result.body, function (err) {
47 + if (err) {
48 + res.statusCode = 500
49 + return res.end("Unexpected Error")
50 + }
51 +
52 + res.statusCode = 200
53 + res.end("Ok")
54 + })
55 + }
56 +}
57 +```
58 +
59 +## Naive Example
60 +
61 +```js
62 +var after = require("after")
63 + , next = after(3, logItWorks)
64 +
65 +next()
66 +next()
67 +next() // it works
68 +
69 +function logItWorks() {
70 + console.log("it works!")
71 +}
72 +```
73 +
74 +## Example with error handling
75 +
76 +```js
77 +var after = require("after")
78 + , next = after(3, logError)
79 +
80 +next()
81 +next(new Error("oops")) // logs oops
82 +next() // does nothing
83 +
84 +// This callback is only called once.
85 +// If there is an error the callback gets called immediately
86 +// this avoids the situation where errors get lost.
87 +function logError(err) {
88 + console.log(err)
89 +}
90 +```
91 +
92 +## Installation
93 +
94 +`npm install after`
95 +
96 +## Tests
97 +
98 +`npm test`
99 +
100 +## Contributors
101 +
102 + - Raynos
103 + - defunctzombie
104 +
105 +## MIT Licenced
106 +
107 + [1]: https://secure.travis-ci.org/Raynos/after.png
108 + [2]: http://travis-ci.org/Raynos/after
109 + [3]: http://raynos.org/blog/2/Flow-control-in-node.js
110 + [4]: http://stackoverflow.com/questions/6852059/determining-the-end-of-asynchronous-operations-javascript/6852307#6852307
111 + [5]: http://stackoverflow.com/questions/6869872/in-javascript-what-are-best-practices-for-executing-multiple-asynchronous-functi/6870031#6870031
112 + [6]: http://stackoverflow.com/questions/6864397/javascript-performance-long-running-tasks/6889419#6889419
113 + [7]: http://stackoverflow.com/questions/6597493/synchronous-database-queries-with-node-js/6620091#6620091
114 + [8]: http://github.com/Raynos/iterators
115 + [9]: http://github.com/Raynos/composite
1 +module.exports = after
2 +
3 +function after(count, callback, err_cb) {
4 + var bail = false
5 + err_cb = err_cb || noop
6 + proxy.count = count
7 +
8 + return (count === 0) ? callback() : proxy
9 +
10 + function proxy(err, result) {
11 + if (proxy.count <= 0) {
12 + throw new Error('after called too many times')
13 + }
14 + --proxy.count
15 +
16 + // after first error, rest are passed to err_cb
17 + if (err) {
18 + bail = true
19 + callback(err)
20 + // future error callbacks will go to error handler
21 + callback = err_cb
22 + } else if (proxy.count === 0 && !bail) {
23 + callback(null, result)
24 + }
25 + }
26 +}
27 +
28 +function noop() {}
1 +{
2 + "_from": "after@0.8.2",
3 + "_id": "after@0.8.2",
4 + "_inBundle": false,
5 + "_integrity": "sha1-/ts5T58OAqqXaOcCvaI7UF+ufh8=",
6 + "_location": "/after",
7 + "_phantomChildren": {},
8 + "_requested": {
9 + "type": "version",
10 + "registry": true,
11 + "raw": "after@0.8.2",
12 + "name": "after",
13 + "escapedName": "after",
14 + "rawSpec": "0.8.2",
15 + "saveSpec": null,
16 + "fetchSpec": "0.8.2"
17 + },
18 + "_requiredBy": [
19 + "/engine.io-parser"
20 + ],
21 + "_resolved": "https://registry.npmjs.org/after/-/after-0.8.2.tgz",
22 + "_shasum": "fedb394f9f0e02aa9768e702bda23b505fae7e1f",
23 + "_spec": "after@0.8.2",
24 + "_where": "C:\\Users\\rkdud\\Desktop\\batch_file\\node_modules\\engine.io-parser",
25 + "author": {
26 + "name": "Raynos",
27 + "email": "raynos2@gmail.com"
28 + },
29 + "bugs": {
30 + "url": "https://github.com/Raynos/after/issues"
31 + },
32 + "bundleDependencies": false,
33 + "contributors": [
34 + {
35 + "name": "Raynos",
36 + "email": "raynos2@gmail.com",
37 + "url": "http://raynos.org"
38 + }
39 + ],
40 + "deprecated": false,
41 + "description": "after - tiny flow control",
42 + "devDependencies": {
43 + "mocha": "~1.8.1"
44 + },
45 + "homepage": "https://github.com/Raynos/after#readme",
46 + "keywords": [
47 + "flowcontrol",
48 + "after",
49 + "flow",
50 + "control",
51 + "arch"
52 + ],
53 + "license": "MIT",
54 + "name": "after",
55 + "repository": {
56 + "type": "git",
57 + "url": "git://github.com/Raynos/after.git"
58 + },
59 + "scripts": {
60 + "test": "mocha --ui tdd --reporter spec test/*.js"
61 + },
62 + "version": "0.8.2"
63 +}
1 +/*global suite, test*/
2 +
3 +var assert = require("assert")
4 + , after = require("../")
5 +
6 +test("exists", function () {
7 + assert(typeof after === "function", "after is not a function")
8 +})
9 +
10 +test("after when called with 0 invokes", function (done) {
11 + after(0, done)
12 +});
13 +
14 +test("after 1", function (done) {
15 + var next = after(1, done)
16 + next()
17 +})
18 +
19 +test("after 5", function (done) {
20 + var next = after(5, done)
21 + , i = 5
22 +
23 + while (i--) {
24 + next()
25 + }
26 +})
27 +
28 +test("manipulate count", function (done) {
29 + var next = after(1, done)
30 + , i = 5
31 +
32 + next.count = i
33 + while (i--) {
34 + next()
35 + }
36 +})
37 +
38 +test("after terminates on error", function (done) {
39 + var next = after(2, function(err) {
40 + assert.equal(err.message, 'test');
41 + done();
42 + })
43 + next(new Error('test'))
44 + next(new Error('test2'))
45 +})
46 +
47 +test('gee', function(done) {
48 + done = after(2, done)
49 +
50 + function cb(err) {
51 + assert.equal(err.message, 1);
52 + done()
53 + }
54 +
55 + var next = after(3, cb, function(err) {
56 + assert.equal(err.message, 2)
57 + done()
58 + });
59 +
60 + next()
61 + next(new Error(1))
62 + next(new Error(2))
63 +})
64 +
65 +test('eee', function(done) {
66 + done = after(3, done)
67 +
68 + function cb(err) {
69 + assert.equal(err.message, 1);
70 + done()
71 + }
72 +
73 + var next = after(3, cb, function(err) {
74 + assert.equal(err.message, 2)
75 + done()
76 + });
77 +
78 + next(new Error(1))
79 + next(new Error(2))
80 + next(new Error(2))
81 +})
82 +
83 +test('gge', function(done) {
84 + function cb(err) {
85 + assert.equal(err.message, 1);
86 + done()
87 + }
88 +
89 + var next = after(3, cb, function(err) {
90 + // should not happen
91 + assert.ok(false);
92 + });
93 +
94 + next()
95 + next()
96 + next(new Error(1))
97 +})
98 +
99 +test('egg', function(done) {
100 + function cb(err) {
101 + assert.equal(err.message, 1);
102 + done()
103 + }
104 +
105 + var next = after(3, cb, function(err) {
106 + // should not happen
107 + assert.ok(false);
108 + });
109 +
110 + next(new Error(1))
111 + next()
112 + next()
113 +})
114 +
115 +test('throws on too many calls', function(done) {
116 + var next = after(1, done);
117 + next()
118 + assert.throws(next, /after called too many times/);
119 +});
120 +
1 +lib-cov
2 +lcov.info
3 +*.seed
4 +*.log
5 +*.csv
6 +*.dat
7 +*.out
8 +*.pid
9 +*.gz
10 +
11 +pids
12 +logs
13 +results
14 +build
15 +.grunt
16 +
17 +node_modules
1 +Copyright (C) 2013 Rase-
2 +
3 +Permission is hereby granted, free of charge, to any person obtaining a copy of
4 +this software and associated documentation files (the "Software"), to deal in
5 +the Software without restriction, including without limitation the rights to
6 +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
7 +of the Software, and to permit persons to whom the Software is furnished to do
8 +so, subject to the following conditions:
9 +
10 +The above copyright notice and this permission notice shall be included in all
11 +copies or substantial portions of the Software.
12 +
13 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
15 +FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
16 +COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
17 +IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
18 +CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1 +
2 +REPORTER = dot
3 +
4 +test:
5 + @./node_modules/.bin/mocha \
6 + --reporter $(REPORTER)
7 +
8 +.PHONY: test
1 +# How to
2 +```javascript
3 +var sliceBuffer = require('arraybuffer.slice');
4 +var ab = (new Int8Array(5)).buffer;
5 +var sliced = sliceBuffer(ab, 1, 3);
6 +sliced = sliceBuffer(ab, 1);
7 +```
8 +
9 +# Licence (MIT)
10 +Copyright (C) 2013 Rase-
11 +
12 +
13 +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
14 +
15 +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
16 +
17 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1 +/**
2 + * An abstraction for slicing an arraybuffer even when
3 + * ArrayBuffer.prototype.slice is not supported
4 + *
5 + * @api public
6 + */
7 +
8 +module.exports = function(arraybuffer, start, end) {
9 + var bytes = arraybuffer.byteLength;
10 + start = start || 0;
11 + end = end || bytes;
12 +
13 + if (arraybuffer.slice) { return arraybuffer.slice(start, end); }
14 +
15 + if (start < 0) { start += bytes; }
16 + if (end < 0) { end += bytes; }
17 + if (end > bytes) { end = bytes; }
18 +
19 + if (start >= bytes || start >= end || bytes === 0) {
20 + return new ArrayBuffer(0);
21 + }
22 +
23 + var abv = new Uint8Array(arraybuffer);
24 + var result = new Uint8Array(end - start);
25 + for (var i = start, ii = 0; i < end; i++, ii++) {
26 + result[ii] = abv[i];
27 + }
28 + return result.buffer;
29 +};
1 +{
2 + "_from": "arraybuffer.slice@~0.0.7",
3 + "_id": "arraybuffer.slice@0.0.7",
4 + "_inBundle": false,
5 + "_integrity": "sha512-wGUIVQXuehL5TCqQun8OW81jGzAWycqzFF8lFp+GOM5BXLYj3bKNsYC4daB7n6XjCqxQA/qgTJ+8ANR3acjrog==",
6 + "_location": "/arraybuffer.slice",
7 + "_phantomChildren": {},
8 + "_requested": {
9 + "type": "range",
10 + "registry": true,
11 + "raw": "arraybuffer.slice@~0.0.7",
12 + "name": "arraybuffer.slice",
13 + "escapedName": "arraybuffer.slice",
14 + "rawSpec": "~0.0.7",
15 + "saveSpec": null,
16 + "fetchSpec": "~0.0.7"
17 + },
18 + "_requiredBy": [
19 + "/engine.io-parser"
20 + ],
21 + "_resolved": "https://registry.npmjs.org/arraybuffer.slice/-/arraybuffer.slice-0.0.7.tgz",
22 + "_shasum": "3bbc4275dd584cc1b10809b89d4e8b63a69e7675",
23 + "_spec": "arraybuffer.slice@~0.0.7",
24 + "_where": "C:\\Users\\rkdud\\Desktop\\batch_file\\node_modules\\engine.io-parser",
25 + "bugs": {
26 + "url": "https://github.com/rase-/arraybuffer.slice/issues"
27 + },
28 + "bundleDependencies": false,
29 + "dependencies": {},
30 + "deprecated": false,
31 + "description": "Exports a function for slicing ArrayBuffers (no polyfilling)",
32 + "devDependencies": {
33 + "expect.js": "0.2.0",
34 + "mocha": "1.17.1"
35 + },
36 + "homepage": "https://github.com/rase-/arraybuffer.slice",
37 + "license": "MIT",
38 + "name": "arraybuffer.slice",
39 + "repository": {
40 + "type": "git",
41 + "url": "git+ssh://git@github.com/rase-/arraybuffer.slice.git"
42 + },
43 + "version": "0.0.7"
44 +}
1 +/*
2 + * Test dependencies
3 + */
4 +
5 +var sliceBuffer = require('../index.js');
6 +var expect = require('expect.js');
7 +
8 +/**
9 + * Tests
10 + */
11 +
12 +describe('sliceBuffer', function() {
13 + describe('using standard slice', function() {
14 + it('should slice correctly with only start provided', function() {
15 + var abv = new Uint8Array(10);
16 + for (var i = 0; i < abv.length; i++) {
17 + abv[i] = i;
18 + }
19 +
20 + var sliced = sliceBuffer(abv.buffer, 3);
21 + var sabv = new Uint8Array(sliced);
22 + for (var i = 3, ii = 0; i < abv.length; i++, ii++) {
23 + expect(abv[i]).to.equal(sabv[ii]);
24 + }
25 + });
26 +
27 + it('should slice correctly with start and end provided', function() {
28 + var abv = new Uint8Array(10);
29 + for (var i = 0; i < abv.length; i++) {
30 + abv[i] = i;
31 + }
32 +
33 + var sliced = sliceBuffer(abv.buffer, 3, 8);
34 + var sabv = new Uint8Array(sliced);
35 + for (var i = 3, ii = 0; i < 8; i++, ii++) {
36 + expect(abv[i]).to.equal(sabv[ii]);
37 + }
38 + });
39 +
40 + it('should slice correctly with negative start', function() {
41 + var abv = new Uint8Array(10);
42 + for (var i = 0; i < abv.length; i++) {
43 + abv[i] = i;
44 + }
45 +
46 + var sliced = sliceBuffer(abv.buffer, -3);
47 + var sabv = new Uint8Array(sliced);
48 + for (var i = abv.length - 3, ii = 0; i < abv.length; i++, ii++) {
49 + expect(abv[i]).to.equal(sabv[ii]);
50 + }
51 + });
52 +
53 + it('should slice correctly with negative end', function() {
54 + var abv = new Uint8Array(10);
55 + for (var i = 0; i < abv.length; i++) {
56 + abv[i] = i;
57 + }
58 +
59 + var sliced = sliceBuffer(abv.buffer, 0, -3);
60 + var sabv = new Uint8Array(sliced);
61 + for (var i = 0, ii = 0; i < abv.length - 3; i++, ii++) {
62 + expect(abv[i]).to.equal(sabv[ii]);
63 + }
64 + });
65 +
66 + it('should slice correctly with negative start and end', function() {
67 + var abv = new Uint8Array(10);
68 + for (var i = 0; i < abv.length; i++) {
69 + abv[i] = i;
70 + }
71 +
72 + var sliced = sliceBuffer(abv.buffer, -6, -3);
73 + var sabv = new Uint8Array(sliced);
74 + for (var i = abv.length - 6, ii = 0; i < abv.length - 3; i++, ii++) {
75 + expect(abv[i]).to.equal(sabv[ii]);
76 + }
77 + });
78 +
79 + it('should slice correctly with equal start and end', function() {
80 + var abv = new Uint8Array(10);
81 + for (var i = 0; i < abv.length; i++) {
82 + abv[i] = i;
83 + }
84 +
85 + var sliced = sliceBuffer(abv.buffer, 1, 1);
86 + expect(sliced.byteLength).to.equal(0);
87 + });
88 +
89 + it('should slice correctly when end larger than buffer', function() {
90 + var abv = new Uint8Array(10);
91 + for (var i = 0; i < abv.length; i++) {
92 + abv[i] = i;
93 + }
94 +
95 + var sliced = sliceBuffer(abv.buffer, 0, 100);
96 + expect(new Uint8Array(sliced)).to.eql(abv);
97 + });
98 +
99 + it('shoud slice correctly when start larger than end', function() {
100 + var abv = new Uint8Array(10);
101 + for (var i = 0; i < abv.length; i++) {
102 + abv[i] = i;
103 + }
104 +
105 + var sliced = sliceBuffer(abv.buffer, 6, 5);
106 + expect(sliced.byteLength).to.equal(0);
107 + });
108 + });
109 +
110 + describe('using fallback', function() {
111 + it('should slice correctly with only start provided', function() {
112 + var abv = new Uint8Array(10);
113 + for (var i = 0; i < abv.length; i++) {
114 + abv[i] = i;
115 + }
116 + var ab = abv.buffer;
117 + ab.slice = undefined;
118 +
119 + var sliced = sliceBuffer(ab, 3);
120 + var sabv = new Uint8Array(sliced);
121 + for (var i = 3, ii = 0; i < abv.length; i++, ii++) {
122 + expect(abv[i]).to.equal(sabv[ii]);
123 + }
124 + });
125 +
126 + it('should slice correctly with start and end provided', function() {
127 + var abv = new Uint8Array(10);
128 + for (var i = 0; i < abv.length; i++) {
129 + abv[i] = i;
130 + }
131 + var ab = abv.buffer;
132 + ab.slice = undefined;
133 +
134 +
135 + var sliced = sliceBuffer(ab, 3, 8);
136 + var sabv = new Uint8Array(sliced);
137 + for (var i = 3, ii = 0; i < 8; i++, ii++) {
138 + expect(abv[i]).to.equal(sabv[ii]);
139 + }
140 + });
141 +
142 + it('should slice correctly with negative start', function() {
143 + var abv = new Uint8Array(10);
144 + for (var i = 0; i < abv.length; i++) {
145 + abv[i] = i;
146 + }
147 + var ab = abv.buffer;
148 + ab.slice = undefined;
149 +
150 +
151 + var sliced = sliceBuffer(ab, -3);
152 + var sabv = new Uint8Array(sliced);
153 + for (var i = abv.length - 3, ii = 0; i < abv.length; i++, ii++) {
154 + expect(abv[i]).to.equal(sabv[ii]);
155 + }
156 + });
157 +
158 + it('should slice correctly with negative end', function() {
159 + var abv = new Uint8Array(10);
160 + for (var i = 0; i < abv.length; i++) {
161 + abv[i] = i;
162 + }
163 + var ab = abv.buffer;
164 + ab.slice = undefined;
165 +
166 + var sliced = sliceBuffer(ab, 0, -3);
167 + var sabv = new Uint8Array(sliced);
168 + for (var i = 0, ii = 0; i < abv.length - 3; i++, ii++) {
169 + expect(abv[i]).to.equal(sabv[ii]);
170 + }
171 + });
172 +
173 + it('should slice correctly with negative start and end', function() {
174 + var abv = new Uint8Array(10);
175 + for (var i = 0; i < abv.length; i++) {
176 + abv[i] = i;
177 + }
178 + var ab = abv.buffer;
179 + ab.slice = undefined;
180 +
181 + var sliced = sliceBuffer(ab, -6, -3);
182 + var sabv = new Uint8Array(sliced);
183 + for (var i = abv.length - 6, ii = 0; i < abv.length - 3; i++, ii++) {
184 + expect(abv[i]).to.equal(sabv[ii]);
185 + }
186 + });
187 +
188 + it('should slice correctly with equal start and end', function() {
189 + var abv = new Uint8Array(10);
190 + for (var i = 0; i < abv.length; i++) {
191 + abv[i] = i;
192 + }
193 + var ab = abv.buffer;
194 + ab.slice = undefined;
195 +
196 + var sliced = sliceBuffer(ab, 1, 1);
197 + expect(sliced.byteLength).to.equal(0);
198 + });
199 +
200 + it('should slice correctly when end larger than buffer', function() {
201 + var abv = new Uint8Array(10);
202 + for (var i = 0; i < abv.length; i++) {
203 + abv[i] = i;
204 + }
205 + var ab = abv.buffer;
206 + ab.slice = undefined;
207 +
208 + var sliced = sliceBuffer(ab, 0, 100);
209 + var sabv = new Uint8Array(sliced);
210 + for (var i = 0; i < abv.length; i++) {
211 + expect(abv[i]).to.equal(sabv[i]);
212 + }
213 + });
214 +
215 + it('shoud slice correctly when start larger than end', function() {
216 + var abv = new Uint8Array(10);
217 + for (var i = 0; i < abv.length; i++) {
218 + abv[i] = i;
219 + }
220 + var ab = abv.buffer;
221 + ab.slice = undefined;
222 +
223 + var sliced = sliceBuffer(ab, 6, 5);
224 + expect(sliced.byteLength).to.equal(0);
225 + });
226 + });
227 +});
1 +coverage
2 +.nyc_output
...\ No newline at end of file ...\ No newline at end of file
1 +{
2 + "check-coverage": false,
3 + "lines": 99,
4 + "statements": 99,
5 + "functions": 99,
6 + "branches": 99,
7 + "include": [
8 + "index.js"
9 + ]
10 +}
...\ No newline at end of file ...\ No newline at end of file
1 +language: node_js
2 +node_js:
3 + - "6"
4 + - "8"
5 + - "10"
6 + - "node"
7 +script: npm run travis
8 +cache:
9 + yarn: true
1 +The MIT License (MIT)
2 +Copyright (c) 2017 Samuel Reed <samuel.trace.reed@gmail.com>
3 +
4 +Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
5 +
6 +The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
7 +
8 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1 +'use strict';
2 +
3 +function Queue(options) {
4 + if (!(this instanceof Queue)) {
5 + return new Queue(options);
6 + }
7 +
8 + options = options || {};
9 + this.concurrency = options.concurrency || Infinity;
10 + this.pending = 0;
11 + this.jobs = [];
12 + this.cbs = [];
13 + this._done = done.bind(this);
14 +}
15 +
16 +var arrayAddMethods = [
17 + 'push',
18 + 'unshift',
19 + 'splice'
20 +];
21 +
22 +arrayAddMethods.forEach(function(method) {
23 + Queue.prototype[method] = function() {
24 + var methodResult = Array.prototype[method].apply(this.jobs, arguments);
25 + this._run();
26 + return methodResult;
27 + };
28 +});
29 +
30 +Object.defineProperty(Queue.prototype, 'length', {
31 + get: function() {
32 + return this.pending + this.jobs.length;
33 + }
34 +});
35 +
36 +Queue.prototype._run = function() {
37 + if (this.pending === this.concurrency) {
38 + return;
39 + }
40 + if (this.jobs.length) {
41 + var job = this.jobs.shift();
42 + this.pending++;
43 + job(this._done);
44 + this._run();
45 + }
46 +
47 + if (this.pending === 0) {
48 + while (this.cbs.length !== 0) {
49 + var cb = this.cbs.pop();
50 + process.nextTick(cb);
51 + }
52 + }
53 +};
54 +
55 +Queue.prototype.onDone = function(cb) {
56 + if (typeof cb === 'function') {
57 + this.cbs.push(cb);
58 + this._run();
59 + }
60 +};
61 +
62 +function done() {
63 + this.pending--;
64 + this._run();
65 +}
66 +
67 +module.exports = Queue;
1 +{
2 + "_from": "async-limiter@~1.0.0",
3 + "_id": "async-limiter@1.0.1",
4 + "_inBundle": false,
5 + "_integrity": "sha512-csOlWGAcRFJaI6m+F2WKdnMKr4HhdhFVBk0H/QbJFMCr+uO2kwohwXQPxw/9OCxp05r5ghVBFSyioixx3gfkNQ==",
6 + "_location": "/async-limiter",
7 + "_phantomChildren": {},
8 + "_requested": {
9 + "type": "range",
10 + "registry": true,
11 + "raw": "async-limiter@~1.0.0",
12 + "name": "async-limiter",
13 + "escapedName": "async-limiter",
14 + "rawSpec": "~1.0.0",
15 + "saveSpec": null,
16 + "fetchSpec": "~1.0.0"
17 + },
18 + "_requiredBy": [
19 + "/engine.io-client/ws"
20 + ],
21 + "_resolved": "https://registry.npmjs.org/async-limiter/-/async-limiter-1.0.1.tgz",
22 + "_shasum": "dd379e94f0db8310b08291f9d64c3209766617fd",
23 + "_spec": "async-limiter@~1.0.0",
24 + "_where": "C:\\Users\\rkdud\\Desktop\\batch_file\\node_modules\\engine.io-client\\node_modules\\ws",
25 + "author": {
26 + "name": "Samuel Reed"
27 + },
28 + "bugs": {
29 + "url": "https://github.com/strml/async-limiter/issues"
30 + },
31 + "bundleDependencies": false,
32 + "dependencies": {},
33 + "deprecated": false,
34 + "description": "asynchronous function queue with adjustable concurrency",
35 + "devDependencies": {
36 + "coveralls": "^3.0.3",
37 + "eslint": "^5.16.0",
38 + "eslint-plugin-mocha": "^5.3.0",
39 + "intelli-espower-loader": "^1.0.1",
40 + "mocha": "^6.1.4",
41 + "nyc": "^14.1.1",
42 + "power-assert": "^1.6.1"
43 + },
44 + "homepage": "https://github.com/strml/async-limiter#readme",
45 + "keywords": [
46 + "throttle",
47 + "async",
48 + "limiter",
49 + "asynchronous",
50 + "job",
51 + "task",
52 + "concurrency",
53 + "concurrent"
54 + ],
55 + "license": "MIT",
56 + "name": "async-limiter",
57 + "repository": {
58 + "type": "git",
59 + "url": "git+https://github.com/strml/async-limiter.git"
60 + },
61 + "scripts": {
62 + "coverage": "nyc npm test && nyc report --reporter=text-lcov | coveralls",
63 + "example": "node example",
64 + "lint": "eslint .",
65 + "test": "mocha --require intelli-espower-loader test/",
66 + "travis": "npm run lint && npm run test"
67 + },
68 + "version": "1.0.1"
69 +}
1 +# Async-Limiter
2 +
3 +A module for limiting concurrent asynchronous actions in flight. Forked from [queue](https://github.com/jessetane/queue).
4 +
5 +[![npm](http://img.shields.io/npm/v/async-limiter.svg?style=flat-square)](http://www.npmjs.org/async-limiter)
6 +[![tests](https://img.shields.io/travis/STRML/async-limiter.svg?style=flat-square&branch=master)](https://travis-ci.org/STRML/async-limiter)
7 +[![coverage](https://img.shields.io/coveralls/STRML/async-limiter.svg?style=flat-square&branch=master)](https://coveralls.io/r/STRML/async-limiter)
8 +
9 +This module exports a class `Limiter` that implements some of the `Array` API.
10 +Pass async functions (ones that accept a callback or return a promise) to an instance's additive array methods.
11 +
12 +## Motivation
13 +
14 +Certain functions, like `zlib`, have [undesirable behavior](https://github.com/nodejs/node/issues/8871#issuecomment-250915913) when
15 +run at infinite concurrency.
16 +
17 +In this case, it is actually faster, and takes far less memory, to limit concurrency.
18 +
19 +This module should do the absolute minimum work necessary to queue up functions. PRs are welcome that would
20 +make this module faster or lighter, but new functionality is not desired.
21 +
22 +Style should confirm to nodejs/node style.
23 +
24 +## Example
25 +
26 +``` javascript
27 +var Limiter = require('async-limiter')
28 +
29 +var t = new Limiter({concurrency: 2});
30 +var results = []
31 +
32 +// add jobs using the familiar Array API
33 +t.push(function (cb) {
34 + results.push('two')
35 + cb()
36 +})
37 +
38 +t.push(
39 + function (cb) {
40 + results.push('four')
41 + cb()
42 + },
43 + function (cb) {
44 + results.push('five')
45 + cb()
46 + }
47 +)
48 +
49 +t.unshift(function (cb) {
50 + results.push('one')
51 + cb()
52 +})
53 +
54 +t.splice(2, 0, function (cb) {
55 + results.push('three')
56 + cb()
57 +})
58 +
59 +// Jobs run automatically. If you want a callback when all are done,
60 +// call 'onDone()'.
61 +t.onDone(function () {
62 + console.log('all done:', results)
63 +})
64 +```
65 +
66 +## Zlib Example
67 +
68 +```js
69 +const zlib = require('zlib');
70 +const Limiter = require('async-limiter');
71 +
72 +const message = {some: "data"};
73 +const payload = new Buffer(JSON.stringify(message));
74 +
75 +// Try with different concurrency values to see how this actually
76 +// slows significantly with higher concurrency!
77 +//
78 +// 5: 1398.607ms
79 +// 10: 1375.668ms
80 +// Infinity: 4423.300ms
81 +//
82 +const t = new Limiter({concurrency: 5});
83 +function deflate(payload, cb) {
84 + t.push(function(done) {
85 + zlib.deflate(payload, function(err, buffer) {
86 + done();
87 + cb(err, buffer);
88 + });
89 + });
90 +}
91 +
92 +console.time('deflate');
93 +for(let i = 0; i < 30000; ++i) {
94 + deflate(payload, function (err, buffer) {});
95 +}
96 +t.onDone(function() {
97 + console.timeEnd('deflate');
98 +});
99 +```
100 +
101 +## Install
102 +
103 +`npm install async-limiter`
104 +
105 +## Test
106 +
107 +`npm test`
108 +
109 +## API
110 +
111 +### `var t = new Limiter([opts])`
112 +Constructor. `opts` may contain inital values for:
113 +* `t.concurrency`
114 +
115 +## Instance methods
116 +
117 +### `t.onDone(fn)`
118 +`fn` will be called once and only once, when the queue is empty.
119 +
120 +## Instance methods mixed in from `Array`
121 +Mozilla has docs on how these methods work [here](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array).
122 +### `t.push(element1, ..., elementN)`
123 +### `t.unshift(element1, ..., elementN)`
124 +### `t.splice(index , howMany[, element1[, ...[, elementN]]])`
125 +
126 +## Properties
127 +### `t.concurrency`
128 +Max number of jobs the queue should process concurrently, defaults to `Infinity`.
129 +
130 +### `t.length`
131 +Jobs pending + jobs to process (readonly).
132 +
1 +
2 +1.0.1 / 2014-02-17
3 +==================
4 +
5 + * go away decimal point
6 + * history
7 +
8 +1.0.0 / 2014-02-17
9 +==================
10 +
11 + * add jitter option
12 + * Initial commit
1 +
2 +test:
3 + @./node_modules/.bin/mocha \
4 + --require should \
5 + --reporter dot \
6 + --bail
7 +
8 +.PHONY: test
...\ No newline at end of file ...\ No newline at end of file
1 +# backo
2 +
3 + Simple exponential backoff because the others seem to have weird abstractions.
4 +
5 +## Installation
6 +
7 +```
8 +$ npm install backo
9 +```
10 +
11 +## Options
12 +
13 + - `min` initial timeout in milliseconds [100]
14 + - `max` max timeout [10000]
15 + - `jitter` [0]
16 + - `factor` [2]
17 +
18 +## Example
19 +
20 +```js
21 +var Backoff = require('backo');
22 +var backoff = new Backoff({ min: 100, max: 20000 });
23 +
24 +setTimeout(function(){
25 + something.reconnect();
26 +}, backoff.duration());
27 +
28 +// later when something works
29 +backoff.reset()
30 +```
31 +
32 +# License
33 +
34 + MIT
1 +{
2 + "name": "backo",
3 + "repo": "segmentio/backo",
4 + "dependencies": {},
5 + "version": "1.0.1",
6 + "description": "simple backoff without the weird abstractions",
7 + "keywords": ["backoff"],
8 + "license": "MIT",
9 + "scripts": ["index.js"],
10 + "main": "index.js"
11 +}
1 +
2 +/**
3 + * Expose `Backoff`.
4 + */
5 +
6 +module.exports = Backoff;
7 +
8 +/**
9 + * Initialize backoff timer with `opts`.
10 + *
11 + * - `min` initial timeout in milliseconds [100]
12 + * - `max` max timeout [10000]
13 + * - `jitter` [0]
14 + * - `factor` [2]
15 + *
16 + * @param {Object} opts
17 + * @api public
18 + */
19 +
20 +function Backoff(opts) {
21 + opts = opts || {};
22 + this.ms = opts.min || 100;
23 + this.max = opts.max || 10000;
24 + this.factor = opts.factor || 2;
25 + this.jitter = opts.jitter > 0 && opts.jitter <= 1 ? opts.jitter : 0;
26 + this.attempts = 0;
27 +}
28 +
29 +/**
30 + * Return the backoff duration.
31 + *
32 + * @return {Number}
33 + * @api public
34 + */
35 +
36 +Backoff.prototype.duration = function(){
37 + var ms = this.ms * Math.pow(this.factor, this.attempts++);
38 + if (this.jitter) {
39 + var rand = Math.random();
40 + var deviation = Math.floor(rand * this.jitter * ms);
41 + ms = (Math.floor(rand * 10) & 1) == 0 ? ms - deviation : ms + deviation;
42 + }
43 + return Math.min(ms, this.max) | 0;
44 +};
45 +
46 +/**
47 + * Reset the number of attempts.
48 + *
49 + * @api public
50 + */
51 +
52 +Backoff.prototype.reset = function(){
53 + this.attempts = 0;
54 +};
55 +
56 +/**
57 + * Set the minimum duration
58 + *
59 + * @api public
60 + */
61 +
62 +Backoff.prototype.setMin = function(min){
63 + this.ms = min;
64 +};
65 +
66 +/**
67 + * Set the maximum duration
68 + *
69 + * @api public
70 + */
71 +
72 +Backoff.prototype.setMax = function(max){
73 + this.max = max;
74 +};
75 +
76 +/**
77 + * Set the jitter
78 + *
79 + * @api public
80 + */
81 +
82 +Backoff.prototype.setJitter = function(jitter){
83 + this.jitter = jitter;
84 +};
85 +
1 +{
2 + "_from": "backo2@1.0.2",
3 + "_id": "backo2@1.0.2",
4 + "_inBundle": false,
5 + "_integrity": "sha1-MasayLEpNjRj41s+u2n038+6eUc=",
6 + "_location": "/backo2",
7 + "_phantomChildren": {},
8 + "_requested": {
9 + "type": "version",
10 + "registry": true,
11 + "raw": "backo2@1.0.2",
12 + "name": "backo2",
13 + "escapedName": "backo2",
14 + "rawSpec": "1.0.2",
15 + "saveSpec": null,
16 + "fetchSpec": "1.0.2"
17 + },
18 + "_requiredBy": [
19 + "/socket.io-client"
20 + ],
21 + "_resolved": "https://registry.npmjs.org/backo2/-/backo2-1.0.2.tgz",
22 + "_shasum": "31ab1ac8b129363463e35b3ebb69f4dfcfba7947",
23 + "_spec": "backo2@1.0.2",
24 + "_where": "C:\\Users\\rkdud\\Desktop\\batch_file\\node_modules\\socket.io-client",
25 + "bugs": {
26 + "url": "https://github.com/mokesmokes/backo/issues"
27 + },
28 + "bundleDependencies": false,
29 + "dependencies": {},
30 + "deprecated": false,
31 + "description": "simple backoff based on segmentio/backo",
32 + "devDependencies": {
33 + "mocha": "*",
34 + "should": "*"
35 + },
36 + "homepage": "https://github.com/mokesmokes/backo#readme",
37 + "keywords": [
38 + "backoff"
39 + ],
40 + "license": "MIT",
41 + "name": "backo2",
42 + "repository": {
43 + "type": "git",
44 + "url": "git+https://github.com/mokesmokes/backo.git"
45 + },
46 + "version": "1.0.2"
47 +}
1 +
2 +var Backoff = require('..');
3 +var assert = require('assert');
4 +
5 +describe('.duration()', function(){
6 + it('should increase the backoff', function(){
7 + var b = new Backoff;
8 +
9 + assert(100 == b.duration());
10 + assert(200 == b.duration());
11 + assert(400 == b.duration());
12 + assert(800 == b.duration());
13 +
14 + b.reset();
15 + assert(100 == b.duration());
16 + assert(200 == b.duration());
17 + })
18 +})
...\ No newline at end of file ...\ No newline at end of file
1 +/node_modules/
2 +Gruntfile.js
3 +/test/
1 +language: node_js
2 +node_js:
3 +- '0.12'
4 +- iojs-1
5 +- iojs-2
6 +- iojs-3
7 +- '4.1'
8 +before_script:
9 +- npm install
10 +before_install: npm install -g npm@'>=2.13.5'
11 +deploy:
12 + provider: npm
13 + email: niklasvh@gmail.com
14 + api_key:
15 + secure: oHV9ArprTj5WOk7MP1UF7QMJ70huXw+y7xXb5wF4+V2H8Hyfa5TfE0DiOmqrube1WXTeH1FLgq54shp/sJWi47Hkg/GyeoB5NnsPhYEaJkaON9UG5blML+ODiNVsEnq/1kNBQ8e0+0JItMPLGySKyFmuZ3yflulXKS8O88mfINo=
16 + on:
17 + tags: true
18 + branch: master
19 + repo: niklasvh/base64-arraybuffer
1 +Copyright (c) 2012 Niklas von Hertzen
2 +
3 +Permission is hereby granted, free of charge, to any person
4 +obtaining a copy of this software and associated documentation
5 +files (the "Software"), to deal in the Software without
6 +restriction, including without limitation the rights to use,
7 +copy, modify, merge, publish, distribute, sublicense, and/or sell
8 +copies of the Software, and to permit persons to whom the
9 +Software is furnished to do so, subject to the following
10 +conditions:
11 +
12 +The above copyright notice and this permission notice shall be
13 +included in all copies or substantial portions of the Software.
14 +
15 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17 +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19 +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20 +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 +OTHER DEALINGS IN THE SOFTWARE.
1 +# base64-arraybuffer
2 +
3 +[![Build Status](https://travis-ci.org/niklasvh/base64-arraybuffer.png)](https://travis-ci.org/niklasvh/base64-arraybuffer)
4 +[![NPM Downloads](https://img.shields.io/npm/dm/base64-arraybuffer.svg)](https://www.npmjs.org/package/base64-arraybuffer)
5 +[![NPM Version](https://img.shields.io/npm/v/base64-arraybuffer.svg)](https://www.npmjs.org/package/base64-arraybuffer)
6 +
7 +Encode/decode base64 data into ArrayBuffers
8 +
9 +## Getting Started
10 +Install the module with: `npm install base64-arraybuffer`
11 +
12 +## API
13 +The library encodes and decodes base64 to and from ArrayBuffers
14 +
15 + - __encode(buffer)__ - Encodes `ArrayBuffer` into base64 string
16 + - __decode(str)__ - Decodes base64 string to `ArrayBuffer`
17 +
18 +## License
19 +Copyright (c) 2012 Niklas von Hertzen
20 +Licensed under the MIT license.
1 +/*
2 + * base64-arraybuffer
3 + * https://github.com/niklasvh/base64-arraybuffer
4 + *
5 + * Copyright (c) 2012 Niklas von Hertzen
6 + * Licensed under the MIT license.
7 + */
8 +(function(chars){
9 + "use strict";
10 +
11 + exports.encode = function(arraybuffer) {
12 + var bytes = new Uint8Array(arraybuffer),
13 + i, len = bytes.length, base64 = "";
14 +
15 + for (i = 0; i < len; i+=3) {
16 + base64 += chars[bytes[i] >> 2];
17 + base64 += chars[((bytes[i] & 3) << 4) | (bytes[i + 1] >> 4)];
18 + base64 += chars[((bytes[i + 1] & 15) << 2) | (bytes[i + 2] >> 6)];
19 + base64 += chars[bytes[i + 2] & 63];
20 + }
21 +
22 + if ((len % 3) === 2) {
23 + base64 = base64.substring(0, base64.length - 1) + "=";
24 + } else if (len % 3 === 1) {
25 + base64 = base64.substring(0, base64.length - 2) + "==";
26 + }
27 +
28 + return base64;
29 + };
30 +
31 + exports.decode = function(base64) {
32 + var bufferLength = base64.length * 0.75,
33 + len = base64.length, i, p = 0,
34 + encoded1, encoded2, encoded3, encoded4;
35 +
36 + if (base64[base64.length - 1] === "=") {
37 + bufferLength--;
38 + if (base64[base64.length - 2] === "=") {
39 + bufferLength--;
40 + }
41 + }
42 +
43 + var arraybuffer = new ArrayBuffer(bufferLength),
44 + bytes = new Uint8Array(arraybuffer);
45 +
46 + for (i = 0; i < len; i+=4) {
47 + encoded1 = chars.indexOf(base64[i]);
48 + encoded2 = chars.indexOf(base64[i+1]);
49 + encoded3 = chars.indexOf(base64[i+2]);
50 + encoded4 = chars.indexOf(base64[i+3]);
51 +
52 + bytes[p++] = (encoded1 << 2) | (encoded2 >> 4);
53 + bytes[p++] = ((encoded2 & 15) << 4) | (encoded3 >> 2);
54 + bytes[p++] = ((encoded3 & 3) << 6) | (encoded4 & 63);
55 + }
56 +
57 + return arraybuffer;
58 + };
59 +})("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/");
1 +{
2 + "_from": "base64-arraybuffer@0.1.4",
3 + "_id": "base64-arraybuffer@0.1.4",
4 + "_inBundle": false,
5 + "_integrity": "sha1-mBjHngWbE1X5fgQooBfIOOkLqBI=",
6 + "_location": "/base64-arraybuffer",
7 + "_phantomChildren": {},
8 + "_requested": {
9 + "type": "version",
10 + "registry": true,
11 + "raw": "base64-arraybuffer@0.1.4",
12 + "name": "base64-arraybuffer",
13 + "escapedName": "base64-arraybuffer",
14 + "rawSpec": "0.1.4",
15 + "saveSpec": null,
16 + "fetchSpec": "0.1.4"
17 + },
18 + "_requiredBy": [
19 + "/engine.io-parser"
20 + ],
21 + "_resolved": "https://registry.npmjs.org/base64-arraybuffer/-/base64-arraybuffer-0.1.4.tgz",
22 + "_shasum": "9818c79e059b1355f97e0428a017c838e90ba812",
23 + "_spec": "base64-arraybuffer@0.1.4",
24 + "_where": "C:\\Users\\rkdud\\Desktop\\batch_file\\node_modules\\engine.io-parser",
25 + "author": {
26 + "name": "Niklas von Hertzen",
27 + "email": "niklasvh@gmail.com",
28 + "url": "http://hertzen.com"
29 + },
30 + "bugs": {
31 + "url": "https://github.com/niklasvh/base64-arraybuffer/issues"
32 + },
33 + "bundleDependencies": false,
34 + "deprecated": false,
35 + "description": "Encode/decode base64 data into ArrayBuffers",
36 + "devDependencies": {
37 + "grunt": "^0.4.5",
38 + "grunt-cli": "^0.1.13",
39 + "grunt-contrib-jshint": "^0.11.2",
40 + "grunt-contrib-nodeunit": "^0.4.1",
41 + "grunt-contrib-watch": "^0.6.1"
42 + },
43 + "engines": {
44 + "node": ">= 0.6.0"
45 + },
46 + "homepage": "https://github.com/niklasvh/base64-arraybuffer",
47 + "keywords": [],
48 + "licenses": [
49 + {
50 + "type": "MIT",
51 + "url": "https://github.com/niklasvh/base64-arraybuffer/blob/master/LICENSE-MIT"
52 + }
53 + ],
54 + "main": "lib/base64-arraybuffer",
55 + "name": "base64-arraybuffer",
56 + "repository": {
57 + "type": "git",
58 + "url": "git+https://github.com/niklasvh/base64-arraybuffer.git"
59 + },
60 + "scripts": {
61 + "test": "grunt nodeunit"
62 + },
63 + "version": "0.1.4"
64 +}
1 +# [2.0.0](https://github.com/faeldt/base64id/compare/1.0.0...2.0.0) (2019-05-27)
2 +
3 +
4 +### Code Refactoring
5 +
6 +* **buffer:** replace deprecated Buffer constructor usage ([#11](https://github.com/faeldt/base64id/issues/11)) ([ccfba54](https://github.com/faeldt/base64id/commit/ccfba54))
7 +
8 +
9 +### BREAKING CHANGES
10 +
11 +* **buffer:** drop support for Node.js ≤ 4.4.x and 5.0.0 - 5.9.x
12 +
13 +See: https://nodejs.org/en/docs/guides/buffer-constructor-deprecation/
14 +
15 +
16 +
1 +(The MIT License)
2 +
3 +Copyright (c) 2012-2016 Kristian Faeldt <faeldt_kristian@cyberagent.co.jp>
4 +
5 +Permission is hereby granted, free of charge, to any person obtaining
6 +a copy of this software and associated documentation files (the
7 +'Software'), to deal in the Software without restriction, including
8 +without limitation the rights to use, copy, modify, merge, publish,
9 +distribute, sublicense, and/or sell copies of the Software, and to
10 +permit persons to whom the Software is furnished to do so, subject to
11 +the following conditions:
12 +
13 +The above copyright notice and this permission notice shall be
14 +included in all copies or substantial portions of the Software.
15 +
16 +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
17 +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20 +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21 +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22 +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1 +base64id
2 +========
3 +
4 +Node.js module that generates a base64 id.
5 +
6 +Uses crypto.randomBytes when available, falls back to unsafe methods for node.js <= 0.4.
7 +
8 +To increase performance, random bytes are buffered to minimize the number of synchronous calls to crypto.randomBytes.
9 +
10 +## Installation
11 +
12 + $ npm install base64id
13 +
14 +## Usage
15 +
16 + var base64id = require('base64id');
17 +
18 + var id = base64id.generateId();
1 +/*!
2 + * base64id v0.1.0
3 + */
4 +
5 +/**
6 + * Module dependencies
7 + */
8 +
9 +var crypto = require('crypto');
10 +
11 +/**
12 + * Constructor
13 + */
14 +
15 +var Base64Id = function() { };
16 +
17 +/**
18 + * Get random bytes
19 + *
20 + * Uses a buffer if available, falls back to crypto.randomBytes
21 + */
22 +
23 +Base64Id.prototype.getRandomBytes = function(bytes) {
24 +
25 + var BUFFER_SIZE = 4096
26 + var self = this;
27 +
28 + bytes = bytes || 12;
29 +
30 + if (bytes > BUFFER_SIZE) {
31 + return crypto.randomBytes(bytes);
32 + }
33 +
34 + var bytesInBuffer = parseInt(BUFFER_SIZE/bytes);
35 + var threshold = parseInt(bytesInBuffer*0.85);
36 +
37 + if (!threshold) {
38 + return crypto.randomBytes(bytes);
39 + }
40 +
41 + if (this.bytesBufferIndex == null) {
42 + this.bytesBufferIndex = -1;
43 + }
44 +
45 + if (this.bytesBufferIndex == bytesInBuffer) {
46 + this.bytesBuffer = null;
47 + this.bytesBufferIndex = -1;
48 + }
49 +
50 + // No buffered bytes available or index above threshold
51 + if (this.bytesBufferIndex == -1 || this.bytesBufferIndex > threshold) {
52 +
53 + if (!this.isGeneratingBytes) {
54 + this.isGeneratingBytes = true;
55 + crypto.randomBytes(BUFFER_SIZE, function(err, bytes) {
56 + self.bytesBuffer = bytes;
57 + self.bytesBufferIndex = 0;
58 + self.isGeneratingBytes = false;
59 + });
60 + }
61 +
62 + // Fall back to sync call when no buffered bytes are available
63 + if (this.bytesBufferIndex == -1) {
64 + return crypto.randomBytes(bytes);
65 + }
66 + }
67 +
68 + var result = this.bytesBuffer.slice(bytes*this.bytesBufferIndex, bytes*(this.bytesBufferIndex+1));
69 + this.bytesBufferIndex++;
70 +
71 + return result;
72 +}
73 +
74 +/**
75 + * Generates a base64 id
76 + *
77 + * (Original version from socket.io <http://socket.io>)
78 + */
79 +
80 +Base64Id.prototype.generateId = function () {
81 + var rand = Buffer.alloc(15); // multiple of 3 for base64
82 + if (!rand.writeInt32BE) {
83 + return Math.abs(Math.random() * Math.random() * Date.now() | 0).toString()
84 + + Math.abs(Math.random() * Math.random() * Date.now() | 0).toString();
85 + }
86 + this.sequenceNumber = (this.sequenceNumber + 1) | 0;
87 + rand.writeInt32BE(this.sequenceNumber, 11);
88 + if (crypto.randomBytes) {
89 + this.getRandomBytes(12).copy(rand);
90 + } else {
91 + // not secure for node 0.4
92 + [0, 4, 8].forEach(function(i) {
93 + rand.writeInt32BE(Math.random() * Math.pow(2, 32) | 0, i);
94 + });
95 + }
96 + return rand.toString('base64').replace(/\//g, '_').replace(/\+/g, '-');
97 +};
98 +
99 +/**
100 + * Export
101 + */
102 +
103 +exports = module.exports = new Base64Id();
1 +{
2 + "_from": "base64id@2.0.0",
3 + "_id": "base64id@2.0.0",
4 + "_inBundle": false,
5 + "_integrity": "sha512-lGe34o6EHj9y3Kts9R4ZYs/Gr+6N7MCaMlIFA3F1R2O5/m7K06AxfSeO5530PEERE6/WyEg3lsuyw4GHlPZHog==",
6 + "_location": "/base64id",
7 + "_phantomChildren": {},
8 + "_requested": {
9 + "type": "version",
10 + "registry": true,
11 + "raw": "base64id@2.0.0",
12 + "name": "base64id",
13 + "escapedName": "base64id",
14 + "rawSpec": "2.0.0",
15 + "saveSpec": null,
16 + "fetchSpec": "2.0.0"
17 + },
18 + "_requiredBy": [
19 + "/engine.io"
20 + ],
21 + "_resolved": "https://registry.npmjs.org/base64id/-/base64id-2.0.0.tgz",
22 + "_shasum": "2770ac6bc47d312af97a8bf9a634342e0cd25cb6",
23 + "_spec": "base64id@2.0.0",
24 + "_where": "C:\\Users\\rkdud\\Desktop\\batch_file\\node_modules\\engine.io",
25 + "author": {
26 + "name": "Kristian Faeldt",
27 + "email": "faeldt_kristian@cyberagent.co.jp"
28 + },
29 + "bugs": {
30 + "url": "https://github.com/faeldt/base64id/issues"
31 + },
32 + "bundleDependencies": false,
33 + "deprecated": false,
34 + "description": "Generates a base64 id",
35 + "engines": {
36 + "node": "^4.5.0 || >= 5.9"
37 + },
38 + "homepage": "https://github.com/faeldt/base64id#readme",
39 + "license": "MIT",
40 + "main": "./lib/base64id.js",
41 + "name": "base64id",
42 + "repository": {
43 + "type": "git",
44 + "url": "git+https://github.com/faeldt/base64id.git"
45 + },
46 + "version": "2.0.0"
47 +}
1 +support
2 +test
3 +examples
4 +*.sock
1 +
2 +1.0.0 / 2013-02-03
3 +==================
4 +
5 + * Stop using the removed magic __stack global getter
6 +
7 +0.1.0 / 2012-10-04
8 +==================
9 +
10 + * add throwing of AssertionError for test frameworks etc
11 +
12 +0.0.1 / 2010-01-03
13 +==================
14 +
15 + * Initial release
1 +
2 +test:
3 + @echo "populate me"
4 +
5 +.PHONY: test
...\ No newline at end of file ...\ No newline at end of file
1 +
2 +# better-assert
3 +
4 + Better c-style assertions using [callsite](https://github.com/visionmedia/callsite) for
5 + self-documenting failure messages.
6 +
7 +## Installation
8 +
9 + $ npm install better-assert
10 +
11 +## Example
12 +
13 + By default assertions are enabled, however the __NO_ASSERT__ environment variable
14 + will deactivate them when truthy.
15 +
16 +```js
17 +var assert = require('better-assert');
18 +
19 +test();
20 +
21 +function test() {
22 + var user = { name: 'tobi' };
23 + assert('tobi' == user.name);
24 + assert('number' == typeof user.age);
25 +}
26 +
27 +AssertionError: 'number' == typeof user.age
28 + at test (/Users/tj/projects/better-assert/example.js:9:3)
29 + at Object.<anonymous> (/Users/tj/projects/better-assert/example.js:4:1)
30 + at Module._compile (module.js:449:26)
31 + at Object.Module._extensions..js (module.js:467:10)
32 + at Module.load (module.js:356:32)
33 + at Function.Module._load (module.js:312:12)
34 + at Module.runMain (module.js:492:10)
35 + at process.startup.processNextTick.process._tickCallback (node.js:244:9)
36 +```
37 +
38 +## License
39 +
40 +(The MIT License)
41 +
42 +Copyright (c) 2012 TJ Holowaychuk &lt;tj@vision-media.ca&gt;
43 +
44 +Permission is hereby granted, free of charge, to any person obtaining
45 +a copy of this software and associated documentation files (the
46 +'Software'), to deal in the Software without restriction, including
47 +without limitation the rights to use, copy, modify, merge, publish,
48 +distribute, sublicense, and/or sell copies of the Software, and to
49 +permit persons to whom the Software is furnished to do so, subject to
50 +the following conditions:
51 +
52 +The above copyright notice and this permission notice shall be
53 +included in all copies or substantial portions of the Software.
54 +
55 +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
56 +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
57 +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
58 +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
59 +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
60 +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
61 +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
...\ No newline at end of file ...\ No newline at end of file
1 +
2 +var assert = require('./');
3 +
4 +test();
5 +
6 +function test() {
7 + var user = { name: 'tobi' };
8 + assert('tobi' == user.name);
9 + assert('number' == typeof user.age);
10 +}
...\ No newline at end of file ...\ No newline at end of file
1 +/**
2 + * Module dependencies.
3 + */
4 +
5 +var AssertionError = require('assert').AssertionError
6 + , callsite = require('callsite')
7 + , fs = require('fs')
8 +
9 +/**
10 + * Expose `assert`.
11 + */
12 +
13 +module.exports = process.env.NO_ASSERT
14 + ? function(){}
15 + : assert;
16 +
17 +/**
18 + * Assert the given `expr`.
19 + */
20 +
21 +function assert(expr) {
22 + if (expr) return;
23 +
24 + var stack = callsite();
25 + var call = stack[1];
26 + var file = call.getFileName();
27 + var lineno = call.getLineNumber();
28 + var src = fs.readFileSync(file, 'utf8');
29 + var line = src.split('\n')[lineno-1];
30 + var src = line.match(/assert\((.*)\)/)[1];
31 +
32 + var err = new AssertionError({
33 + message: src,
34 + stackStartFunction: stack[0].getFunction()
35 + });
36 +
37 + throw err;
38 +}
1 +{
2 + "_from": "better-assert@~1.0.0",
3 + "_id": "better-assert@1.0.2",
4 + "_inBundle": false,
5 + "_integrity": "sha1-QIZrnhueC1W0gYlDEeaPr/rrxSI=",
6 + "_location": "/better-assert",
7 + "_phantomChildren": {},
8 + "_requested": {
9 + "type": "range",
10 + "registry": true,
11 + "raw": "better-assert@~1.0.0",
12 + "name": "better-assert",
13 + "escapedName": "better-assert",
14 + "rawSpec": "~1.0.0",
15 + "saveSpec": null,
16 + "fetchSpec": "~1.0.0"
17 + },
18 + "_requiredBy": [
19 + "/parseqs",
20 + "/parseuri"
21 + ],
22 + "_resolved": "https://registry.npmjs.org/better-assert/-/better-assert-1.0.2.tgz",
23 + "_shasum": "40866b9e1b9e0b55b481894311e68faffaebc522",
24 + "_spec": "better-assert@~1.0.0",
25 + "_where": "C:\\Users\\rkdud\\Desktop\\batch_file\\node_modules\\parseqs",
26 + "author": {
27 + "name": "TJ Holowaychuk",
28 + "email": "tj@vision-media.ca"
29 + },
30 + "bugs": {
31 + "url": "https://github.com/visionmedia/better-assert/issues"
32 + },
33 + "bundleDependencies": false,
34 + "contributors": [
35 + {
36 + "name": "TonyHe",
37 + "email": "coolhzb@163.com"
38 + },
39 + {
40 + "name": "ForbesLindesay"
41 + }
42 + ],
43 + "dependencies": {
44 + "callsite": "1.0.0"
45 + },
46 + "deprecated": false,
47 + "description": "Better assertions for node, reporting the expr, filename, lineno etc",
48 + "engines": {
49 + "node": "*"
50 + },
51 + "homepage": "https://github.com/visionmedia/better-assert#readme",
52 + "keywords": [
53 + "assert",
54 + "stack",
55 + "trace",
56 + "debug"
57 + ],
58 + "main": "index",
59 + "name": "better-assert",
60 + "repository": {
61 + "type": "git",
62 + "url": "git+https://github.com/visionmedia/better-assert.git"
63 + },
64 + "version": "1.0.2"
65 +}
1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<module type="WEB_MODULE" version="4">
3 + <component name="NewModuleRootManager">
4 + <content url="file://$MODULE_DIR$">
5 + <excludeFolder url="file://$MODULE_DIR$/.tmp" />
6 + <excludeFolder url="file://$MODULE_DIR$/temp" />
7 + <excludeFolder url="file://$MODULE_DIR$/tmp" />
8 + </content>
9 + <orderEntry type="inheritedJdk" />
10 + <orderEntry type="sourceFolder" forTests="false" />
11 + </component>
12 +</module>
...\ No newline at end of file ...\ No newline at end of file
1 +<component name="InspectionProjectProfileManager">
2 + <settings>
3 + <option name="PROJECT_PROFILE" />
4 + </settings>
5 +</component>
...\ No newline at end of file ...\ No newline at end of file
1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<project version="4">
3 + <component name="MarkdownProjectSettings" wasCopied="true">
4 + <PreviewSettings splitEditorLayout="SPLIT" splitEditorPreview="PREVIEW" useGrayscaleRendering="false" zoomFactor="1.0" maxImageWidth="0" showGitHubPageIfSynced="false" allowBrowsingInPreview="false" synchronizePreviewPosition="true" highlightPreviewType="NONE" highlightFadeOut="5" highlightOnTyping="true" synchronizeSourcePosition="true" verticallyAlignSourceAndPreviewSyncPosition="true" showSearchHighlightsInPreview="false" showSelectionInPreview="true" openRemoteLinks="true" replaceUnicodeEmoji="false" lastLayoutSetsDefault="false">
5 + <PanelProvider>
6 + <provider providerId="com.vladsch.idea.multimarkdown.editor.swing.html.panel" providerName="Default - Swing" />
7 + </PanelProvider>
8 + </PreviewSettings>
9 + <ParserSettings gitHubSyntaxChange="false" emojiShortcuts="1" emojiImages="0">
10 + <PegdownExtensions>
11 + <option name="ABBREVIATIONS" value="false" />
12 + <option name="ANCHORLINKS" value="true" />
13 + <option name="ASIDE" value="false" />
14 + <option name="ATXHEADERSPACE" value="true" />
15 + <option name="AUTOLINKS" value="true" />
16 + <option name="DEFINITIONS" value="false" />
17 + <option name="DEFINITION_BREAK_DOUBLE_BLANK_LINE" value="false" />
18 + <option name="FENCED_CODE_BLOCKS" value="true" />
19 + <option name="FOOTNOTES" value="false" />
20 + <option name="HARDWRAPS" value="false" />
21 + <option name="HTML_DEEP_PARSER" value="false" />
22 + <option name="INSERTED" value="false" />
23 + <option name="QUOTES" value="false" />
24 + <option name="RELAXEDHRULES" value="true" />
25 + <option name="SMARTS" value="false" />
26 + <option name="STRIKETHROUGH" value="true" />
27 + <option name="SUBSCRIPT" value="false" />
28 + <option name="SUPERSCRIPT" value="false" />
29 + <option name="SUPPRESS_HTML_BLOCKS" value="false" />
30 + <option name="SUPPRESS_INLINE_HTML" value="false" />
31 + <option name="TABLES" value="true" />
32 + <option name="TASKLISTITEMS" value="true" />
33 + <option name="TOC" value="false" />
34 + <option name="WIKILINKS" value="true" />
35 + </PegdownExtensions>
36 + <ParserOptions>
37 + <option name="ADMONITION_EXT" value="false" />
38 + <option name="ATTRIBUTES_EXT" value="false" />
39 + <option name="COMMONMARK_LISTS" value="true" />
40 + <option name="DUMMY" value="false" />
41 + <option name="EMOJI_SHORTCUTS" value="true" />
42 + <option name="ENUMERATED_REFERENCES_EXT" value="false" />
43 + <option name="FLEXMARK_FRONT_MATTER" value="false" />
44 + <option name="GFM_LOOSE_BLANK_LINE_AFTER_ITEM_PARA" value="false" />
45 + <option name="GFM_TABLE_RENDERING" value="true" />
46 + <option name="GITBOOK_URL_ENCODING" value="false" />
47 + <option name="GITHUB_LISTS" value="false" />
48 + <option name="GITHUB_WIKI_LINKS" value="true" />
49 + <option name="HEADER_ID_NO_DUPED_DASHES" value="false" />
50 + <option name="JEKYLL_FRONT_MATTER" value="false" />
51 + <option name="NO_TEXT_ATTRIBUTES" value="false" />
52 + <option name="PARSE_HTML_ANCHOR_ID" value="false" />
53 + <option name="SIM_TOC_BLANK_LINE_SPACER" value="true" />
54 + </ParserOptions>
55 + </ParserSettings>
56 + <HtmlSettings headerTopEnabled="false" headerBottomEnabled="false" bodyTopEnabled="false" bodyBottomEnabled="false" embedUrlContent="false" addPageHeader="true" embedImages="false" embedHttpImages="false" imageUriSerials="false">
57 + <GeneratorProvider>
58 + <provider providerId="com.vladsch.idea.multimarkdown.editor.swing.html.generator" providerName="Default Swing HTML Generator" />
59 + </GeneratorProvider>
60 + <headerTop />
61 + <headerBottom />
62 + <bodyTop />
63 + <bodyBottom />
64 + </HtmlSettings>
65 + <CssSettings previewScheme="UI_SCHEME" cssUri="" isCssUriEnabled="false" isCssUriSerial="false" isCssTextEnabled="false" isDynamicPageWidth="true">
66 + <StylesheetProvider>
67 + <provider providerId="com.vladsch.idea.multimarkdown.editor.swing.html.css" providerName="Default Swing Stylesheet" />
68 + </StylesheetProvider>
69 + <ScriptProviders />
70 + <cssText />
71 + <cssUriHistory />
72 + </CssSettings>
73 + <HtmlExportSettings updateOnSave="false" parentDir="" targetDir="" cssDir="" scriptDir="" plainHtml="false" imageDir="" copyLinkedImages="false" imageUniquifyType="0" targetExt="" useTargetExt="false" noCssNoScripts="false" linkToExportedHtml="true" exportOnSettingsChange="true" regenerateOnProjectOpen="false" linkFormatType="HTTP_ABSOLUTE" />
74 + <LinkMapSettings>
75 + <textMaps />
76 + </LinkMapSettings>
77 + </component>
78 +</project>
...\ No newline at end of file ...\ No newline at end of file
1 +<component name="MarkdownNavigator.ProfileManager">
2 + <settings default="" pdf-export="" />
3 +</component>
...\ No newline at end of file ...\ No newline at end of file
1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<project version="4">
3 + <component name="ProjectModuleManager">
4 + <modules>
5 + <module fileurl="file://$PROJECT_DIR$/.idea/blob.iml" filepath="$PROJECT_DIR$/.idea/blob.iml" />
6 + </modules>
7 + </component>
8 +</project>
...\ No newline at end of file ...\ No newline at end of file
1 +<?xml version="1.0" encoding="UTF-8"?>
2 +<project version="4">
3 + <component name="VcsDirectoryMappings">
4 + <mapping directory="$PROJECT_DIR$" vcs="Git" />
5 + </component>
6 +</project>
...\ No newline at end of file ...\ No newline at end of file
This diff is collapsed. Click to expand it.
1 +ui: mocha-bdd
2 +browsers:
3 + - name: chrome
4 + version: 8..latest
5 + - name: firefox
6 + version: 7..latest
7 + - name: safari
8 + version: 6..latest
9 + - name: opera
10 + version: 12.1..latest
11 + - name: ie
12 + version: 10..latest
13 + - name: android
14 + version: latest
1 +MIT License
2 +
3 +Copyright (C) 2014 Rase-
4 +
5 +Permission is hereby granted, free of charge, to any person obtaining a copy of
6 +this software and associated documentation files (the "Software"), to deal in
7 +the Software without restriction, including without limitation the rights to
8 +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 +the Software, and to permit persons to whom the Software is furnished to do so,
10 +subject to the following conditions:
11 +
12 +The above copyright notice and this permission notice shall be included in all
13 +copies or substantial portions of the Software.
14 +
15 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 +SOFTWARE.
1 +REPORTER = dot
2 +
3 +build: blob.js
4 +
5 +blob.js:
6 + @./node_modules/.bin/browserify --standalone blob index.js > blob.js
7 +
8 +test:
9 + @./node_modules/.bin/zuul -- test/index.js
10 +
11 +clean:
12 + rm blob.js
13 +
14 +.PHONY: test blob.js
1 +# Blob
2 +
3 +A cross-browser `Blob` that falls back to `BlobBuilder` when appropriate.
4 +If neither is available, it exports `undefined`.
5 +
6 +## Installation
7 +
8 +``` bash
9 +$ npm install blob
10 +```
11 +
12 +## Example
13 +
14 +``` js
15 +var Blob = require('blob');
16 +var b = new Blob(['hi', 'constructing', 'a', 'blob']);
17 +```
18 +
19 +## License
20 +
21 +MIT
1 +{
2 + "name": "blob",
3 + "repo": "webmodules/blob",
4 + "description": "Abstracts out Blob and uses BlobBulder in cases where it is supported with any vendor prefix.",
5 + "version": "0.0.4",
6 + "license": "MIT",
7 + "dependencies": {},
8 + "scripts": [
9 + "index.js"
10 + ]
11 +}
1 +/**
2 + * Create a blob builder even when vendor prefixes exist
3 + */
4 +
5 +var BlobBuilder = typeof BlobBuilder !== 'undefined' ? BlobBuilder :
6 + typeof WebKitBlobBuilder !== 'undefined' ? WebKitBlobBuilder :
7 + typeof MSBlobBuilder !== 'undefined' ? MSBlobBuilder :
8 + typeof MozBlobBuilder !== 'undefined' ? MozBlobBuilder :
9 + false;
10 +
11 +/**
12 + * Check if Blob constructor is supported
13 + */
14 +
15 +var blobSupported = (function() {
16 + try {
17 + var a = new Blob(['hi']);
18 + return a.size === 2;
19 + } catch(e) {
20 + return false;
21 + }
22 +})();
23 +
24 +/**
25 + * Check if Blob constructor supports ArrayBufferViews
26 + * Fails in Safari 6, so we need to map to ArrayBuffers there.
27 + */
28 +
29 +var blobSupportsArrayBufferView = blobSupported && (function() {
30 + try {
31 + var b = new Blob([new Uint8Array([1,2])]);
32 + return b.size === 2;
33 + } catch(e) {
34 + return false;
35 + }
36 +})();
37 +
38 +/**
39 + * Check if BlobBuilder is supported
40 + */
41 +
42 +var blobBuilderSupported = BlobBuilder
43 + && BlobBuilder.prototype.append
44 + && BlobBuilder.prototype.getBlob;
45 +
46 +/**
47 + * Helper function that maps ArrayBufferViews to ArrayBuffers
48 + * Used by BlobBuilder constructor and old browsers that didn't
49 + * support it in the Blob constructor.
50 + */
51 +
52 +function mapArrayBufferViews(ary) {
53 + return ary.map(function(chunk) {
54 + if (chunk.buffer instanceof ArrayBuffer) {
55 + var buf = chunk.buffer;
56 +
57 + // if this is a subarray, make a copy so we only
58 + // include the subarray region from the underlying buffer
59 + if (chunk.byteLength !== buf.byteLength) {
60 + var copy = new Uint8Array(chunk.byteLength);
61 + copy.set(new Uint8Array(buf, chunk.byteOffset, chunk.byteLength));
62 + buf = copy.buffer;
63 + }
64 +
65 + return buf;
66 + }
67 +
68 + return chunk;
69 + });
70 +}
71 +
72 +function BlobBuilderConstructor(ary, options) {
73 + options = options || {};
74 +
75 + var bb = new BlobBuilder();
76 + mapArrayBufferViews(ary).forEach(function(part) {
77 + bb.append(part);
78 + });
79 +
80 + return (options.type) ? bb.getBlob(options.type) : bb.getBlob();
81 +};
82 +
83 +function BlobConstructor(ary, options) {
84 + return new Blob(mapArrayBufferViews(ary), options || {});
85 +};
86 +
87 +if (typeof Blob !== 'undefined') {
88 + BlobBuilderConstructor.prototype = Blob.prototype;
89 + BlobConstructor.prototype = Blob.prototype;
90 +}
91 +
92 +module.exports = (function() {
93 + if (blobSupported) {
94 + return blobSupportsArrayBufferView ? Blob : BlobConstructor;
95 + } else if (blobBuilderSupported) {
96 + return BlobBuilderConstructor;
97 + } else {
98 + return undefined;
99 + }
100 +})();
1 +{
2 + "_from": "blob@0.0.5",
3 + "_id": "blob@0.0.5",
4 + "_inBundle": false,
5 + "_integrity": "sha512-gaqbzQPqOoamawKg0LGVd7SzLgXS+JH61oWprSLH+P+abTczqJbhTR8CmJ2u9/bUYNmHTGJx/UEmn6doAvvuig==",
6 + "_location": "/blob",
7 + "_phantomChildren": {},
8 + "_requested": {
9 + "type": "version",
10 + "registry": true,
11 + "raw": "blob@0.0.5",
12 + "name": "blob",
13 + "escapedName": "blob",
14 + "rawSpec": "0.0.5",
15 + "saveSpec": null,
16 + "fetchSpec": "0.0.5"
17 + },
18 + "_requiredBy": [
19 + "/engine.io-parser"
20 + ],
21 + "_resolved": "https://registry.npmjs.org/blob/-/blob-0.0.5.tgz",
22 + "_shasum": "d680eeef25f8cd91ad533f5b01eed48e64caf683",
23 + "_spec": "blob@0.0.5",
24 + "_where": "C:\\Users\\rkdud\\Desktop\\batch_file\\node_modules\\engine.io-parser",
25 + "bugs": {
26 + "url": "https://github.com/webmodules/blob/issues"
27 + },
28 + "bundleDependencies": false,
29 + "dependencies": {},
30 + "deprecated": false,
31 + "description": "Abstracts out Blob and uses BlobBulder in cases where it is supported with any vendor prefix.",
32 + "devDependencies": {
33 + "browserify": "4.2.3",
34 + "expect.js": "0.2.0",
35 + "mocha": "1.17.1",
36 + "zuul": "1.10.2"
37 + },
38 + "homepage": "https://github.com/webmodules/blob",
39 + "license": "MIT",
40 + "name": "blob",
41 + "repository": {
42 + "type": "git",
43 + "url": "git://github.com/webmodules/blob.git"
44 + },
45 + "scripts": {
46 + "test": "make test"
47 + },
48 + "version": "0.0.5"
49 +}
1 +var Blob = require('../');
2 +var expect = require('expect.js');
3 +
4 +describe('blob', function() {
5 + if (!Blob) {
6 + it('should not have a blob or a blob builder in the global namespace, or blob should not be a constructor function if the module exports false', function() {
7 + try {
8 + var ab = (new Uint8Array(5)).buffer;
9 + global.Blob([ab]);
10 + expect().fail('Blob shouldn\'t be constructable');
11 + } catch (e) {}
12 +
13 + var BlobBuilder = global.BlobBuilder
14 + || global.WebKitBlobBuilder
15 + || global.MSBlobBuilder
16 + || global.MozBlobBuilder;
17 + expect(BlobBuilder).to.be(undefined);
18 + });
19 + } else {
20 + it('should encode a proper sized blob when given a string argument', function() {
21 + var b = new Blob(['hi']);
22 + expect(b.size).to.be(2);
23 + });
24 +
25 + it('should encode a blob with proper size when given two strings as arguments', function() {
26 + var b = new Blob(['hi', 'hello']);
27 + expect(b.size).to.be(7);
28 + });
29 +
30 + it('should encode arraybuffers with right content', function(done) {
31 + var ary = new Uint8Array(5);
32 + for (var i = 0; i < 5; i++) ary[i] = i;
33 + var b = new Blob([ary.buffer]);
34 + var fr = new FileReader();
35 + fr.onload = function() {
36 + var newAry = new Uint8Array(this.result);
37 + for (var i = 0; i < 5; i++) expect(newAry[i]).to.be(i);
38 + done();
39 + };
40 + fr.readAsArrayBuffer(b);
41 + });
42 +
43 + it('should encode typed arrays with right content', function(done) {
44 + var ary = new Uint8Array(5);
45 + for (var i = 0; i < 5; i++) ary[i] = i;
46 + var b = new Blob([ary]);
47 + var fr = new FileReader();
48 + fr.onload = function() {
49 + var newAry = new Uint8Array(this.result);
50 + for (var i = 0; i < 5; i++) expect(newAry[i]).to.be(i);
51 + done();
52 + };
53 + fr.readAsArrayBuffer(b);
54 + });
55 +
56 + it('should encode sliced typed arrays with right content', function(done) {
57 + var ary = new Uint8Array(5);
58 + for (var i = 0; i < 5; i++) ary[i] = i;
59 + var b = new Blob([ary.subarray(2)]);
60 + var fr = new FileReader();
61 + fr.onload = function() {
62 + var newAry = new Uint8Array(this.result);
63 + for (var i = 0; i < 3; i++) expect(newAry[i]).to.be(i + 2);
64 + done();
65 + };
66 + fr.readAsArrayBuffer(b);
67 + });
68 +
69 + it('should encode with blobs', function(done) {
70 + var ary = new Uint8Array(5);
71 + for (var i = 0; i < 5; i++) ary[i] = i;
72 + var b = new Blob([new Blob([ary.buffer])]);
73 + var fr = new FileReader();
74 + fr.onload = function() {
75 + var newAry = new Uint8Array(this.result);
76 + for (var i = 0; i < 5; i++) expect(newAry[i]).to.be(i);
77 + done();
78 + };
79 + fr.readAsArrayBuffer(b);
80 + });
81 +
82 + it('should enode mixed contents to right size', function() {
83 + var ary = new Uint8Array(5);
84 + for (var i = 0; i < 5; i++) ary[i] = i;
85 + var b = new Blob([ary.buffer, 'hello']);
86 + expect(b.size).to.be(10);
87 + });
88 +
89 + it('should accept mime type', function() {
90 + var b = new Blob(['hi', 'hello'], { type: 'text/html' });
91 + expect(b.type).to.be('text/html');
92 + });
93 +
94 + it('should be an instance of constructor', function() {
95 + var b = new Blob(['hi']);
96 + expect(b).to.be.a(Blob);
97 + expect(b).to.be.a(global.Blob);
98 + });
99 + }
100 +});
1 +support
2 +test
3 +examples
4 +*.sock
1 +
2 +1.0.0 / 2013-01-24
3 +==================
4 +
5 + * remove lame magical getters
6 +
7 +0.0.1 / 2010-01-03
8 +==================
9 +
10 + * Initial release
1 +
2 +test:
3 + @./node_modules/.bin/mocha \
4 + --require should
5 +
6 +.PHONY: test
...\ No newline at end of file ...\ No newline at end of file
1 +# callstack
2 +
3 + Access to v8's "raw" `CallSite`s.
4 +
5 +## Installation
6 +
7 + $ npm install callsite
8 +
9 +## Example
10 +
11 +```js
12 +var stack = require('callsite');
13 +
14 +foo();
15 +
16 +function foo() {
17 + bar();
18 +}
19 +
20 +function bar() {
21 + baz();
22 +}
23 +
24 +function baz() {
25 + console.log();
26 + stack().forEach(function(site){
27 + console.log(' \033[36m%s\033[90m in %s:%d\033[0m'
28 + , site.getFunctionName() || 'anonymous'
29 + , site.getFileName()
30 + , site.getLineNumber());
31 + });
32 + console.log();
33 +}
34 +```
35 +
36 +## Why?
37 +
38 + Because you can do weird, stupid, clever, wacky things such as:
39 +
40 + - [better-assert](https://github.com/visionmedia/better-assert)
41 +
42 +## License
43 +
44 + MIT
1 +
2 +module.exports = function(){
3 + var orig = Error.prepareStackTrace;
4 + Error.prepareStackTrace = function(_, stack){ return stack; };
5 + var err = new Error;
6 + Error.captureStackTrace(err, arguments.callee);
7 + var stack = err.stack;
8 + Error.prepareStackTrace = orig;
9 + return stack;
10 +};
1 +{
2 + "_from": "callsite@1.0.0",
3 + "_id": "callsite@1.0.0",
4 + "_inBundle": false,
5 + "_integrity": "sha1-KAOY5dZkvXQDi28JBRU+borxvCA=",
6 + "_location": "/callsite",
7 + "_phantomChildren": {},
8 + "_requested": {
9 + "type": "version",
10 + "registry": true,
11 + "raw": "callsite@1.0.0",
12 + "name": "callsite",
13 + "escapedName": "callsite",
14 + "rawSpec": "1.0.0",
15 + "saveSpec": null,
16 + "fetchSpec": "1.0.0"
17 + },
18 + "_requiredBy": [
19 + "/better-assert"
20 + ],
21 + "_resolved": "https://registry.npmjs.org/callsite/-/callsite-1.0.0.tgz",
22 + "_shasum": "280398e5d664bd74038b6f0905153e6e8af1bc20",
23 + "_spec": "callsite@1.0.0",
24 + "_where": "C:\\Users\\rkdud\\Desktop\\batch_file\\node_modules\\better-assert",
25 + "author": {
26 + "name": "TJ Holowaychuk",
27 + "email": "tj@vision-media.ca"
28 + },
29 + "bundleDependencies": false,
30 + "dependencies": {},
31 + "deprecated": false,
32 + "description": "access to v8's CallSites",
33 + "devDependencies": {
34 + "mocha": "*",
35 + "should": "*"
36 + },
37 + "engines": {
38 + "node": "*"
39 + },
40 + "keywords": [
41 + "stack",
42 + "trace",
43 + "line"
44 + ],
45 + "main": "index",
46 + "name": "callsite",
47 + "version": "1.0.0"
48 +}
1 +
2 +1.0.0 / 2014-05-27
3 +==================
4 +
5 + * index: use slice ref (#7, @viatropos)
6 + * package: rename package to "component-bind"
7 + * package: add "repository" field (#6, @repoify)
8 + * package: add "component" section
9 +
10 +0.0.1 / 2010-01-03
11 +==================
12 +
13 + * Initial release
1 +
2 +test:
3 + @./node_modules/.bin/mocha \
4 + --require should \
5 + --reporter spec
6 +
7 +.PHONY: test
...\ No newline at end of file ...\ No newline at end of file
1 +# bind
2 +
3 + Function binding utility.
4 +
5 +## Installation
6 +
7 +```
8 +$ component install component/bind
9 +```
10 +
11 +## API
12 +
13 + - [bind(obj, fn)](#bindobj-fn)
14 + - [bind(obj, fn, ...)](#bindobj-fn-)
15 + - [bind(obj, name)](#bindobj-name)
16 +<a name=""></a>
17 +
18 +<a name="bindobj-fn"></a>
19 +### bind(obj, fn)
20 +should bind the function to the given object.
21 +
22 +```js
23 +var tobi = { name: 'tobi' };
24 +
25 +function name() {
26 + return this.name;
27 +}
28 +
29 +var fn = bind(tobi, name);
30 +fn().should.equal('tobi');
31 +```
32 +
33 +<a name="bindobj-fn-"></a>
34 +### bind(obj, fn, ...)
35 +should curry the remaining arguments.
36 +
37 +```js
38 +function add(a, b) {
39 + return a + b;
40 +}
41 +
42 +bind(null, add)(1, 2).should.equal(3);
43 +bind(null, add, 1)(2).should.equal(3);
44 +bind(null, add, 1, 2)().should.equal(3);
45 +```
46 +
47 +<a name="bindobj-name"></a>
48 +### bind(obj, name)
49 +should bind the method of the given name.
50 +
51 +```js
52 +var tobi = { name: 'tobi' };
53 +
54 +tobi.getName = function() {
55 + return this.name;
56 +};
57 +
58 +var fn = bind(tobi, 'getName');
59 +fn().should.equal('tobi');
60 +```
61 +
62 +## License
63 +
64 + MIT
...\ No newline at end of file ...\ No newline at end of file
1 +{
2 + "name": "bind",
3 + "version": "1.0.0",
4 + "description": "function binding utility",
5 + "keywords": [
6 + "bind",
7 + "utility"
8 + ],
9 + "dependencies": {},
10 + "scripts": [
11 + "index.js"
12 + ]
13 +}
1 +/**
2 + * Slice reference.
3 + */
4 +
5 +var slice = [].slice;
6 +
7 +/**
8 + * Bind `obj` to `fn`.
9 + *
10 + * @param {Object} obj
11 + * @param {Function|String} fn or string
12 + * @return {Function}
13 + * @api public
14 + */
15 +
16 +module.exports = function(obj, fn){
17 + if ('string' == typeof fn) fn = obj[fn];
18 + if ('function' != typeof fn) throw new Error('bind() requires a function');
19 + var args = slice.call(arguments, 2);
20 + return function(){
21 + return fn.apply(obj, args.concat(slice.call(arguments)));
22 + }
23 +};
1 +{
2 + "_from": "component-bind@1.0.0",
3 + "_id": "component-bind@1.0.0",
4 + "_inBundle": false,
5 + "_integrity": "sha1-AMYIq33Nk4l8AAllGx06jh5zu9E=",
6 + "_location": "/component-bind",
7 + "_phantomChildren": {},
8 + "_requested": {
9 + "type": "version",
10 + "registry": true,
11 + "raw": "component-bind@1.0.0",
12 + "name": "component-bind",
13 + "escapedName": "component-bind",
14 + "rawSpec": "1.0.0",
15 + "saveSpec": null,
16 + "fetchSpec": "1.0.0"
17 + },
18 + "_requiredBy": [
19 + "/socket.io-client"
20 + ],
21 + "_resolved": "https://registry.npmjs.org/component-bind/-/component-bind-1.0.0.tgz",
22 + "_shasum": "00c608ab7dcd93897c0009651b1d3a8e1e73bbd1",
23 + "_spec": "component-bind@1.0.0",
24 + "_where": "C:\\Users\\rkdud\\Desktop\\batch_file\\node_modules\\socket.io-client",
25 + "bugs": {
26 + "url": "https://github.com/component/bind/issues"
27 + },
28 + "bundleDependencies": false,
29 + "component": {
30 + "scripts": {
31 + "bind/index.js": "index.js"
32 + }
33 + },
34 + "deprecated": false,
35 + "description": "function binding utility",
36 + "devDependencies": {
37 + "mocha": "*",
38 + "should": "*"
39 + },
40 + "homepage": "https://github.com/component/bind#readme",
41 + "keywords": [
42 + "bind",
43 + "utility"
44 + ],
45 + "name": "component-bind",
46 + "repository": {
47 + "type": "git",
48 + "url": "git+https://github.com/component/bind.git"
49 + },
50 + "version": "1.0.0"
51 +}
1 +
2 +1.2.1 / 2016-04-18
3 +==================
4 +
5 + * enable client side use
6 +
7 +1.2.0 / 2014-02-12
8 +==================
9 +
10 + * prefix events with `$` to support object prototype method names
11 +
12 +1.1.3 / 2014-06-20
13 +==================
14 +
15 + * republish for npm
16 + * add LICENSE file
17 +
18 +1.1.2 / 2014-02-10
19 +==================
20 +
21 + * package: rename to "component-emitter"
22 + * package: update "main" and "component" fields
23 + * Add license to Readme (same format as the other components)
24 + * created .npmignore
25 + * travis stuff
26 +
27 +1.1.1 / 2013-12-01
28 +==================
29 +
30 + * fix .once adding .on to the listener
31 + * docs: Emitter#off()
32 + * component: add `.repo` prop
33 +
34 +1.1.0 / 2013-10-20
35 +==================
36 +
37 + * add `.addEventListener()` and `.removeEventListener()` aliases
38 +
39 +1.0.1 / 2013-06-27
40 +==================
41 +
42 + * add support for legacy ie
43 +
44 +1.0.0 / 2013-02-26
45 +==================
46 +
47 + * add `.off()` support for removing all listeners
48 +
49 +0.0.6 / 2012-10-08
50 +==================
51 +
52 + * add `this._callbacks` initialization to prevent funky gotcha
53 +
54 +0.0.5 / 2012-09-07
55 +==================
56 +
57 + * fix `Emitter.call(this)` usage
58 +
59 +0.0.3 / 2012-07-11
60 +==================
61 +
62 + * add `.listeners()`
63 + * rename `.has()` to `.hasListeners()`
64 +
65 +0.0.2 / 2012-06-28
66 +==================
67 +
68 + * fix `.off()` with `.once()`-registered callbacks
1 +(The MIT License)
2 +
3 +Copyright (c) 2014 Component contributors <dev@component.io>
4 +
5 +Permission is hereby granted, free of charge, to any person
6 +obtaining a copy of this software and associated documentation
7 +files (the "Software"), to deal in the Software without
8 +restriction, including without limitation the rights to use,
9 +copy, modify, merge, publish, distribute, sublicense, and/or sell
10 +copies of the Software, and to permit persons to whom the
11 +Software is furnished to do so, subject to the following
12 +conditions:
13 +
14 +The above copyright notice and this permission notice shall be
15 +included in all copies or substantial portions of the Software.
16 +
17 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
19 +OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 +NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
21 +HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
22 +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
23 +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
24 +OTHER DEALINGS IN THE SOFTWARE.
1 +# Emitter [![Build Status](https://travis-ci.org/component/emitter.png)](https://travis-ci.org/component/emitter)
2 +
3 + Event emitter component.
4 +
5 +## Installation
6 +
7 +```
8 +$ component install component/emitter
9 +```
10 +
11 +## API
12 +
13 +### Emitter(obj)
14 +
15 + The `Emitter` may also be used as a mixin. For example
16 + a "plain" object may become an emitter, or you may
17 + extend an existing prototype.
18 +
19 + As an `Emitter` instance:
20 +
21 +```js
22 +var Emitter = require('emitter');
23 +var emitter = new Emitter;
24 +emitter.emit('something');
25 +```
26 +
27 + As a mixin:
28 +
29 +```js
30 +var Emitter = require('emitter');
31 +var user = { name: 'tobi' };
32 +Emitter(user);
33 +
34 +user.emit('im a user');
35 +```
36 +
37 + As a prototype mixin:
38 +
39 +```js
40 +var Emitter = require('emitter');
41 +Emitter(User.prototype);
42 +```
43 +
44 +### Emitter#on(event, fn)
45 +
46 + Register an `event` handler `fn`.
47 +
48 +### Emitter#once(event, fn)
49 +
50 + Register a single-shot `event` handler `fn`,
51 + removed immediately after it is invoked the
52 + first time.
53 +
54 +### Emitter#off(event, fn)
55 +
56 + * Pass `event` and `fn` to remove a listener.
57 + * Pass `event` to remove all listeners on that event.
58 + * Pass nothing to remove all listeners on all events.
59 +
60 +### Emitter#emit(event, ...)
61 +
62 + Emit an `event` with variable option args.
63 +
64 +### Emitter#listeners(event)
65 +
66 + Return an array of callbacks, or an empty array.
67 +
68 +### Emitter#hasListeners(event)
69 +
70 + Check if this emitter has `event` handlers.
71 +
72 +## License
73 +
74 +MIT
1 +
2 +/**
3 + * Expose `Emitter`.
4 + */
5 +
6 +if (typeof module !== 'undefined') {
7 + module.exports = Emitter;
8 +}
9 +
10 +/**
11 + * Initialize a new `Emitter`.
12 + *
13 + * @api public
14 + */
15 +
16 +function Emitter(obj) {
17 + if (obj) return mixin(obj);
18 +};
19 +
20 +/**
21 + * Mixin the emitter properties.
22 + *
23 + * @param {Object} obj
24 + * @return {Object}
25 + * @api private
26 + */
27 +
28 +function mixin(obj) {
29 + for (var key in Emitter.prototype) {
30 + obj[key] = Emitter.prototype[key];
31 + }
32 + return obj;
33 +}
34 +
35 +/**
36 + * Listen on the given `event` with `fn`.
37 + *
38 + * @param {String} event
39 + * @param {Function} fn
40 + * @return {Emitter}
41 + * @api public
42 + */
43 +
44 +Emitter.prototype.on =
45 +Emitter.prototype.addEventListener = function(event, fn){
46 + this._callbacks = this._callbacks || {};
47 + (this._callbacks['$' + event] = this._callbacks['$' + event] || [])
48 + .push(fn);
49 + return this;
50 +};
51 +
52 +/**
53 + * Adds an `event` listener that will be invoked a single
54 + * time then automatically removed.
55 + *
56 + * @param {String} event
57 + * @param {Function} fn
58 + * @return {Emitter}
59 + * @api public
60 + */
61 +
62 +Emitter.prototype.once = function(event, fn){
63 + function on() {
64 + this.off(event, on);
65 + fn.apply(this, arguments);
66 + }
67 +
68 + on.fn = fn;
69 + this.on(event, on);
70 + return this;
71 +};
72 +
73 +/**
74 + * Remove the given callback for `event` or all
75 + * registered callbacks.
76 + *
77 + * @param {String} event
78 + * @param {Function} fn
79 + * @return {Emitter}
80 + * @api public
81 + */
82 +
83 +Emitter.prototype.off =
84 +Emitter.prototype.removeListener =
85 +Emitter.prototype.removeAllListeners =
86 +Emitter.prototype.removeEventListener = function(event, fn){
87 + this._callbacks = this._callbacks || {};
88 +
89 + // all
90 + if (0 == arguments.length) {
91 + this._callbacks = {};
92 + return this;
93 + }
94 +
95 + // specific event
96 + var callbacks = this._callbacks['$' + event];
97 + if (!callbacks) return this;
98 +
99 + // remove all handlers
100 + if (1 == arguments.length) {
101 + delete this._callbacks['$' + event];
102 + return this;
103 + }
104 +
105 + // remove specific handler
106 + var cb;
107 + for (var i = 0; i < callbacks.length; i++) {
108 + cb = callbacks[i];
109 + if (cb === fn || cb.fn === fn) {
110 + callbacks.splice(i, 1);
111 + break;
112 + }
113 + }
114 + return this;
115 +};
116 +
117 +/**
118 + * Emit `event` with the given args.
119 + *
120 + * @param {String} event
121 + * @param {Mixed} ...
122 + * @return {Emitter}
123 + */
124 +
125 +Emitter.prototype.emit = function(event){
126 + this._callbacks = this._callbacks || {};
127 + var args = [].slice.call(arguments, 1)
128 + , callbacks = this._callbacks['$' + event];
129 +
130 + if (callbacks) {
131 + callbacks = callbacks.slice(0);
132 + for (var i = 0, len = callbacks.length; i < len; ++i) {
133 + callbacks[i].apply(this, args);
134 + }
135 + }
136 +
137 + return this;
138 +};
139 +
140 +/**
141 + * Return array of callbacks for `event`.
142 + *
143 + * @param {String} event
144 + * @return {Array}
145 + * @api public
146 + */
147 +
148 +Emitter.prototype.listeners = function(event){
149 + this._callbacks = this._callbacks || {};
150 + return this._callbacks['$' + event] || [];
151 +};
152 +
153 +/**
154 + * Check if this emitter has `event` handlers.
155 + *
156 + * @param {String} event
157 + * @return {Boolean}
158 + * @api public
159 + */
160 +
161 +Emitter.prototype.hasListeners = function(event){
162 + return !! this.listeners(event).length;
163 +};
1 +{
2 + "_from": "component-emitter@1.2.1",
3 + "_id": "component-emitter@1.2.1",
4 + "_inBundle": false,
5 + "_integrity": "sha1-E3kY1teCg/ffemt8WmPhQOaUJeY=",
6 + "_location": "/component-emitter",
7 + "_phantomChildren": {},
8 + "_requested": {
9 + "type": "version",
10 + "registry": true,
11 + "raw": "component-emitter@1.2.1",
12 + "name": "component-emitter",
13 + "escapedName": "component-emitter",
14 + "rawSpec": "1.2.1",
15 + "saveSpec": null,
16 + "fetchSpec": "1.2.1"
17 + },
18 + "_requiredBy": [
19 + "/socket.io-client",
20 + "/socket.io-parser"
21 + ],
22 + "_resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.2.1.tgz",
23 + "_shasum": "137918d6d78283f7df7a6b7c5a63e140e69425e6",
24 + "_spec": "component-emitter@1.2.1",
25 + "_where": "C:\\Users\\rkdud\\Desktop\\batch_file\\node_modules\\socket.io-client",
26 + "bugs": {
27 + "url": "https://github.com/component/emitter/issues"
28 + },
29 + "bundleDependencies": false,
30 + "component": {
31 + "scripts": {
32 + "emitter/index.js": "index.js"
33 + }
34 + },
35 + "deprecated": false,
36 + "description": "Event emitter",
37 + "devDependencies": {
38 + "mocha": "*",
39 + "should": "*"
40 + },
41 + "files": [
42 + "index.js",
43 + "LICENSE"
44 + ],
45 + "homepage": "https://github.com/component/emitter#readme",
46 + "license": "MIT",
47 + "main": "index.js",
48 + "name": "component-emitter",
49 + "repository": {
50 + "type": "git",
51 + "url": "git+https://github.com/component/emitter.git"
52 + },
53 + "scripts": {
54 + "test": "make test"
55 + },
56 + "version": "1.2.1"
57 +}
1 +
2 +0.0.2 / 2012-09-03
3 +==================
4 +
5 + * fix typo in package.json
1 +
2 +build: components index.js
3 + @component build
4 +
5 +components:
6 + @Component install
7 +
8 +clean:
9 + rm -fr build components template.js
10 +
11 +test:
12 + @node_modules/.bin/mocha \
13 + --require should \
14 + --reporter spec
15 +
16 +.PHONY: clean test
1 +# inherit
2 +
3 + Prototype inheritance utility.
4 +
5 +## Installation
6 +
7 +```
8 +$ component install component/inherit
9 +```
10 +
11 +## Example
12 +
13 +```js
14 +var inherit = require('inherit');
15 +
16 +function Human() {}
17 +function Woman() {}
18 +
19 +inherit(Woman, Human);
20 +```
21 +
22 +## License
23 +
24 + MIT
1 +{
2 + "name": "inherit",
3 + "description": "Prototype inheritance utility",
4 + "version": "0.0.3",
5 + "keywords": ["inherit", "utility"],
6 + "dependencies": {},
7 + "scripts": [
8 + "index.js"
9 + ]
10 +}
1 +
2 +module.exports = function(a, b){
3 + var fn = function(){};
4 + fn.prototype = b.prototype;
5 + a.prototype = new fn;
6 + a.prototype.constructor = a;
7 +};
...\ No newline at end of file ...\ No newline at end of file
1 +{
2 + "_from": "component-inherit@0.0.3",
3 + "_id": "component-inherit@0.0.3",
4 + "_inBundle": false,
5 + "_integrity": "sha1-ZF/ErfWLcrZJ1crmUTVhnbJv8UM=",
6 + "_location": "/component-inherit",
7 + "_phantomChildren": {},
8 + "_requested": {
9 + "type": "version",
10 + "registry": true,
11 + "raw": "component-inherit@0.0.3",
12 + "name": "component-inherit",
13 + "escapedName": "component-inherit",
14 + "rawSpec": "0.0.3",
15 + "saveSpec": null,
16 + "fetchSpec": "0.0.3"
17 + },
18 + "_requiredBy": [
19 + "/engine.io-client"
20 + ],
21 + "_resolved": "https://registry.npmjs.org/component-inherit/-/component-inherit-0.0.3.tgz",
22 + "_shasum": "645fc4adf58b72b649d5cae65135619db26ff143",
23 + "_spec": "component-inherit@0.0.3",
24 + "_where": "C:\\Users\\rkdud\\Desktop\\batch_file\\node_modules\\engine.io-client",
25 + "bugs": {
26 + "url": "https://github.com/component/inherit/issues"
27 + },
28 + "bundleDependencies": false,
29 + "component": {
30 + "scripts": {
31 + "inherit/index.js": "index.js"
32 + }
33 + },
34 + "dependencies": {},
35 + "deprecated": false,
36 + "description": "Prototype inheritance utility",
37 + "homepage": "https://github.com/component/inherit#readme",
38 + "keywords": [
39 + "inherit",
40 + "utility"
41 + ],
42 + "name": "component-inherit",
43 + "repository": {
44 + "type": "git",
45 + "url": "git+https://github.com/component/inherit.git"
46 + },
47 + "version": "0.0.3"
48 +}
1 +
2 +/**
3 + * Module dependencies.
4 + */
5 +
6 +var inherit = require('..');
7 +
8 +describe('inherit(a, b)', function(){
9 + it('should inherit b\'s prototype', function(){
10 + function Loki(){}
11 + function Animal(){}
12 +
13 + Animal.prototype.species = 'unknown';
14 +
15 + inherit(Loki, Animal);
16 +
17 + var loki = new Loki;
18 + loki.species.should.equal('unknown');
19 + loki.constructor.should.equal(Loki);
20 + })
21 +})
...\ No newline at end of file ...\ No newline at end of file
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.