fsevents 1.0.8 → 1.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of fsevents might be problematic. Click here for more details.
- package/node_modules/ansi-styles/index.js +72 -6
- package/node_modules/ansi-styles/package.json +19 -12
- package/node_modules/ansi-styles/readme.md +36 -8
- package/node_modules/are-we-there-yet/CHANGES.md +19 -0
- package/node_modules/are-we-there-yet/README.md +12 -2
- package/node_modules/are-we-there-yet/index.js +4 -132
- package/node_modules/are-we-there-yet/package.json +18 -13
- package/node_modules/are-we-there-yet/test/lib/test-event.js +29 -0
- package/node_modules/are-we-there-yet/test/tracker.js +44 -43
- package/node_modules/are-we-there-yet/test/trackergroup.js +73 -64
- package/node_modules/are-we-there-yet/test/trackerstream.js +26 -40
- package/node_modules/are-we-there-yet/tracker-base.js +11 -0
- package/node_modules/are-we-there-yet/tracker-group.js +107 -0
- package/node_modules/are-we-there-yet/tracker-stream.js +35 -0
- package/node_modules/are-we-there-yet/tracker.js +30 -0
- package/node_modules/asn1/package.json +1 -2
- package/node_modules/assert-plus/package.json +1 -3
- package/node_modules/async/package.json +1 -1
- package/node_modules/aws4/.npmignore +2 -1
- package/node_modules/aws4/README.md +4 -0
- package/node_modules/aws4/aws4.js +8 -3
- package/node_modules/aws4/node_modules/lru-cache/.npmignore +3 -0
- package/node_modules/aws4/node_modules/lru-cache/.travis.yml +3 -4
- package/node_modules/aws4/node_modules/lru-cache/README.md +29 -24
- package/node_modules/aws4/node_modules/lru-cache/benchmarks/insertion-time.js +32 -0
- package/node_modules/aws4/node_modules/lru-cache/lib/lru-cache.js +333 -199
- package/node_modules/aws4/node_modules/lru-cache/node_modules/pseudomap/LICENSE +15 -0
- package/node_modules/aws4/node_modules/lru-cache/node_modules/pseudomap/README.md +60 -0
- package/node_modules/aws4/node_modules/lru-cache/node_modules/pseudomap/map.js +9 -0
- package/node_modules/aws4/node_modules/lru-cache/node_modules/pseudomap/package.json +59 -0
- package/node_modules/aws4/node_modules/lru-cache/node_modules/pseudomap/pseudomap.js +113 -0
- package/node_modules/aws4/node_modules/lru-cache/node_modules/pseudomap/test/basic.js +86 -0
- package/node_modules/aws4/node_modules/lru-cache/node_modules/yallist/.npmignore +4 -0
- package/node_modules/aws4/node_modules/lru-cache/node_modules/yallist/.travis.yml +7 -0
- package/node_modules/aws4/node_modules/lru-cache/node_modules/yallist/CONTRIBUTING.md +4 -0
- package/node_modules/aws4/node_modules/lru-cache/node_modules/yallist/LICENSE +15 -0
- package/node_modules/aws4/node_modules/lru-cache/node_modules/yallist/README.md +204 -0
- package/node_modules/aws4/node_modules/lru-cache/node_modules/yallist/package.json +59 -0
- package/node_modules/aws4/node_modules/lru-cache/node_modules/yallist/test/basic.js +188 -0
- package/node_modules/aws4/node_modules/lru-cache/node_modules/yallist/yallist.js +360 -0
- package/node_modules/aws4/node_modules/lru-cache/package.json +16 -12
- package/node_modules/aws4/node_modules/lru-cache/test/basic.js +270 -146
- package/node_modules/aws4/node_modules/lru-cache/test/foreach.js +39 -25
- package/node_modules/aws4/node_modules/lru-cache/test/inspect.js +54 -0
- package/node_modules/aws4/node_modules/lru-cache/test/no-symbol.js +3 -0
- package/node_modules/aws4/node_modules/lru-cache/test/serialize.js +115 -104
- package/node_modules/aws4/package.json +17 -14
- package/node_modules/bl/bl.js +9 -3
- package/node_modules/bl/package.json +12 -12
- package/node_modules/bl/test/test.js +14 -0
- package/node_modules/color-convert/README.md +62 -0
- package/node_modules/color-convert/conversions.js +594 -0
- package/node_modules/color-convert/css-keywords.js +151 -0
- package/node_modules/color-convert/index.js +75 -0
- package/node_modules/color-convert/package.json +92 -0
- package/node_modules/color-convert/route.js +98 -0
- package/node_modules/dashdash/lib/dashdash.js +1 -1
- package/node_modules/dashdash/node_modules/assert-plus/AUTHORS +6 -0
- package/node_modules/dashdash/node_modules/assert-plus/CHANGES.md +14 -0
- package/node_modules/dashdash/node_modules/assert-plus/README.md +162 -0
- package/node_modules/dashdash/node_modules/assert-plus/assert.js +211 -0
- package/node_modules/dashdash/node_modules/assert-plus/package.json +89 -0
- package/node_modules/dashdash/package.json +19 -12
- package/node_modules/ecc-jsbn/package.json +1 -2
- package/node_modules/escape-string-regexp/package.json +15 -11
- package/node_modules/extsprintf/package.json +2 -3
- package/node_modules/form-data/.dockerignore +7 -0
- package/node_modules/form-data/.editorconfig +10 -0
- package/node_modules/form-data/.eslintignore +1 -0
- package/node_modules/form-data/.eslintrc +64 -0
- package/node_modules/form-data/{Readme.md → README.md} +9 -1
- package/node_modules/form-data/lib/browser.js +2 -1
- package/node_modules/form-data/lib/form_data.js +172 -135
- package/node_modules/form-data/lib/populate.js +9 -0
- package/node_modules/form-data/package.json +35 -16
- package/node_modules/form-data/wercker.yml +36 -0
- package/node_modules/fstream-ignore/node_modules/minimatch/node_modules/brace-expansion/index.js +1 -1
- package/node_modules/fstream-ignore/node_modules/minimatch/node_modules/brace-expansion/package.json +14 -10
- package/node_modules/gauge/README.md +1 -1
- package/node_modules/gauge/package.json +18 -14
- package/node_modules/gauge/progress-bar.js +2 -2
- package/node_modules/http-signature/package.json +1 -2
- package/node_modules/is-my-json-valid/README.md +2 -2
- package/node_modules/is-my-json-valid/index.js +15 -6
- package/node_modules/is-my-json-valid/package.json +11 -7
- package/node_modules/is-my-json-valid/test/json-schema-draft4/multipleOf.json +36 -0
- package/node_modules/is-my-json-valid/test/misc.js +18 -0
- package/node_modules/is-typedarray/package.json +1 -2
- package/node_modules/isarray/.npmignore +1 -0
- package/node_modules/isarray/.travis.yml +4 -0
- package/node_modules/isarray/Makefile +6 -0
- package/node_modules/isarray/README.md +6 -0
- package/node_modules/isarray/index.js +3 -1
- package/node_modules/isarray/package.json +28 -10
- package/node_modules/isarray/test.js +20 -0
- package/node_modules/jodid25519/package.json +1 -2
- package/node_modules/jsbn/package.json +1 -2
- package/node_modules/json-schema/package.json +1 -1
- package/node_modules/jsprim/package.json +1 -2
- package/node_modules/lodash.pad/LICENSE +17 -16
- package/node_modules/lodash.pad/README.md +2 -2
- package/node_modules/lodash.pad/index.js +3 -94
- package/node_modules/lodash.pad/package.json +12 -12
- package/node_modules/lodash.padend/LICENSE +23 -0
- package/node_modules/lodash.padend/README.md +18 -0
- package/node_modules/lodash.padend/index.js +285 -0
- package/node_modules/lodash.padend/package.json +91 -0
- package/node_modules/lodash.padstart/LICENSE +23 -0
- package/node_modules/lodash.padstart/README.md +18 -0
- package/node_modules/lodash.padstart/index.js +285 -0
- package/node_modules/lodash.padstart/package.json +91 -0
- package/node_modules/lodash.repeat/LICENSE +17 -16
- package/node_modules/lodash.repeat/README.md +2 -2
- package/node_modules/lodash.repeat/index.js +3 -94
- package/node_modules/lodash.repeat/package.json +14 -13
- package/node_modules/lodash.tostring/LICENSE +23 -0
- package/node_modules/lodash.tostring/README.md +18 -0
- package/node_modules/lodash.tostring/index.js +164 -0
- package/node_modules/lodash.tostring/package.json +91 -0
- package/node_modules/mime-db/HISTORY.md +14 -0
- package/node_modules/mime-db/db.json +26 -3
- package/node_modules/mime-db/package.json +23 -18
- package/node_modules/mime-types/HISTORY.md +8 -0
- package/node_modules/mime-types/README.md +1 -1
- package/node_modules/mime-types/package.json +21 -16
- package/node_modules/node-pre-gyp/CHANGELOG.md +11 -0
- package/node_modules/node-pre-gyp/lib/util/abi_crosswalk.json +44 -4
- package/node_modules/node-pre-gyp/package.json +16 -16
- package/node_modules/npmlog/.nyc_output/64996.json +1 -0
- package/node_modules/npmlog/.nyc_output/64998.json +1 -0
- package/node_modules/npmlog/.nyc_output/65000.json +1 -0
- package/node_modules/npmlog/log.js +3 -2
- package/node_modules/npmlog/package.json +15 -11
- package/node_modules/npmlog/test/progress.js +25 -8
- package/node_modules/once/package.json +1 -1
- package/node_modules/qs/package.json +1 -2
- package/node_modules/readable-stream/.travis.yml +18 -16
- package/node_modules/readable-stream/README.md +1 -1
- package/node_modules/readable-stream/doc/stream.markdown +435 -405
- package/node_modules/readable-stream/lib/_stream_duplex.js +13 -20
- package/node_modules/readable-stream/lib/_stream_passthrough.js +3 -4
- package/node_modules/readable-stream/lib/_stream_readable.js +110 -205
- package/node_modules/readable-stream/lib/_stream_transform.js +21 -38
- package/node_modules/readable-stream/lib/_stream_writable.js +108 -121
- package/node_modules/readable-stream/package.json +19 -15
- package/node_modules/request/package.json +1 -2
- package/node_modules/rimraf/node_modules/glob/README.md +6 -0
- package/node_modules/rimraf/node_modules/glob/common.js +12 -3
- package/node_modules/rimraf/node_modules/glob/glob.js +20 -3
- package/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/index.js +1 -1
- package/node_modules/rimraf/node_modules/glob/node_modules/minimatch/node_modules/brace-expansion/package.json +14 -10
- package/node_modules/rimraf/node_modules/glob/package.json +15 -11
- package/node_modules/rimraf/node_modules/glob/sync.js +8 -1
- package/node_modules/rimraf/package.json +14 -10
- package/node_modules/semver/package.json +1 -2
- package/node_modules/sshpk/lib/formats/rfc4253.js +2 -1
- package/node_modules/sshpk/package.json +13 -10
- package/node_modules/strip-ansi/package.json +21 -16
- package/node_modules/strip-ansi/readme.md +5 -5
- package/node_modules/tough-cookie/lib/cookie.js +2 -2
- package/node_modules/tough-cookie/package.json +13 -9
- package/node_modules/tweetnacl/CHANGELOG.md +53 -0
- package/node_modules/tweetnacl/COPYING.txt +9 -0
- package/node_modules/tweetnacl/README.md +14 -40
- package/node_modules/tweetnacl/nacl-fast.js +21 -51
- package/node_modules/tweetnacl/nacl-fast.min.js +2 -2
- package/node_modules/tweetnacl/nacl.js +21 -51
- package/node_modules/tweetnacl/nacl.min.js +1 -1
- package/node_modules/tweetnacl/package.json +28 -38
- package/node_modules/verror/package.json +2 -3
- package/package.json +2 -2
- package/node_modules/aws4/example.js +0 -372
- package/node_modules/aws4/node_modules/lru-cache/test/memory-leak.js +0 -51
- package/node_modules/isarray/build/build.js +0 -209
- package/node_modules/lodash._basetostring/LICENSE +0 -22
- package/node_modules/lodash._basetostring/README.md +0 -20
- package/node_modules/lodash._basetostring/index.js +0 -22
- package/node_modules/lodash._basetostring/package.json +0 -99
- package/node_modules/lodash._createpadding/LICENSE +0 -22
- package/node_modules/lodash._createpadding/README.md +0 -20
- package/node_modules/lodash._createpadding/index.js +0 -37
- package/node_modules/lodash._createpadding/package.json +0 -101
- package/node_modules/lodash._root/LICENSE +0 -22
- package/node_modules/lodash._root/README.md +0 -18
- package/node_modules/lodash._root/index.js +0 -53
- package/node_modules/lodash._root/package.json +0 -77
- package/node_modules/lodash.padleft/LICENSE.txt +0 -22
- package/node_modules/lodash.padleft/README.md +0 -20
- package/node_modules/lodash.padleft/index.js +0 -50
- package/node_modules/lodash.padleft/package.json +0 -107
- package/node_modules/lodash.padright/LICENSE.txt +0 -22
- package/node_modules/lodash.padright/README.md +0 -20
- package/node_modules/lodash.padright/index.js +0 -50
- package/node_modules/lodash.padright/package.json +0 -107
@@ -0,0 +1,60 @@
|
|
1
|
+
# pseudomap
|
2
|
+
|
3
|
+
A thing that is a lot like ES6 `Map`, but without iterators, for use
|
4
|
+
in environments where `for..of` syntax and `Map` are not available.
|
5
|
+
|
6
|
+
If you need iterators, or just in general a more faithful polyfill to
|
7
|
+
ES6 Maps, check out [es6-map](http://npm.im/es6-map).
|
8
|
+
|
9
|
+
If you are in an environment where `Map` is supported, then that will
|
10
|
+
be returned instead, unless `process.env.TEST_PSEUDOMAP` is set.
|
11
|
+
|
12
|
+
You can use any value as keys, and any value as data. Setting again
|
13
|
+
with the identical key will overwrite the previous value.
|
14
|
+
|
15
|
+
Internally, data is stored on an `Object.create(null)` style object.
|
16
|
+
The key is coerced to a string to generate the key on the internal
|
17
|
+
data-bag object. The original key used is stored along with the data.
|
18
|
+
|
19
|
+
In the event of a stringified-key collision, a new key is generated by
|
20
|
+
appending an increasing number to the stringified-key until finding
|
21
|
+
either the intended key or an empty spot.
|
22
|
+
|
23
|
+
Note that because object traversal order of plain objects is not
|
24
|
+
guaranteed to be identical to insertion order, the insertion order
|
25
|
+
guarantee of `Map.prototype.forEach` is not guaranteed in this
|
26
|
+
implementation. However, in all versions of Node.js and V8 where this
|
27
|
+
module works, `forEach` does traverse data in insertion order.
|
28
|
+
|
29
|
+
## API
|
30
|
+
|
31
|
+
Most of the [Map
|
32
|
+
API](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Map),
|
33
|
+
with the following exceptions:
|
34
|
+
|
35
|
+
1. A `Map` object is not an iterator.
|
36
|
+
2. `values`, `keys`, and `entries` methods are not implemented,
|
37
|
+
because they return iterators.
|
38
|
+
3. The argument to the constructor can be an Array of `[key, value]`
|
39
|
+
pairs, or a `Map` or `PseudoMap` object. But, since iterators
|
40
|
+
aren't used, passing any plain-old iterator won't initialize the
|
41
|
+
map properly.
|
42
|
+
|
43
|
+
## USAGE
|
44
|
+
|
45
|
+
Use just like a regular ES6 Map.
|
46
|
+
|
47
|
+
```javascript
|
48
|
+
var PseudoMap = require('pseudomap')
|
49
|
+
|
50
|
+
// optionally provide a pseudomap, or an array of [key,value] pairs
|
51
|
+
// as the argument to initialize the map with
|
52
|
+
var myMap = new PseudoMap()
|
53
|
+
|
54
|
+
myMap.set(1, 'number 1')
|
55
|
+
myMap.set('1', 'string 1')
|
56
|
+
var akey = {}
|
57
|
+
var bkey = {}
|
58
|
+
myMap.set(akey, { some: 'data' })
|
59
|
+
myMap.set(bkey, { some: 'other data' })
|
60
|
+
```
|
@@ -0,0 +1,9 @@
|
|
1
|
+
if (process.env.npm_package_name === 'pseudomap' &&
|
2
|
+
process.env.npm_lifecycle_script === 'test')
|
3
|
+
process.env.TEST_PSEUDOMAP = 'true'
|
4
|
+
|
5
|
+
if (typeof Map === 'function' && !process.env.TEST_PSEUDOMAP) {
|
6
|
+
module.exports = Map
|
7
|
+
} else {
|
8
|
+
module.exports = require('./pseudomap')
|
9
|
+
}
|
@@ -0,0 +1,59 @@
|
|
1
|
+
{
|
2
|
+
"_from": "pseudomap@^1.0.1",
|
3
|
+
"_id": "pseudomap@1.0.2",
|
4
|
+
"_location": "/aws4/lru-cache/pseudomap",
|
5
|
+
"_nodeVersion": "4.0.0",
|
6
|
+
"_npmUser": {
|
7
|
+
"email": "i@izs.me",
|
8
|
+
"name": "isaacs"
|
9
|
+
},
|
10
|
+
"_npmVersion": "3.3.2",
|
11
|
+
"_phantomChildren": {},
|
12
|
+
"_requiredBy": [
|
13
|
+
"/aws4/lru-cache"
|
14
|
+
],
|
15
|
+
"_resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz",
|
16
|
+
"_shasum": "f052a28da70e618917ef0a8ac34c1ae5a68286b3",
|
17
|
+
"_shrinkwrap": null,
|
18
|
+
"author": {
|
19
|
+
"email": "i@izs.me",
|
20
|
+
"name": "Isaac Z. Schlueter",
|
21
|
+
"url": "http://blog.izs.me/"
|
22
|
+
},
|
23
|
+
"bugs": {
|
24
|
+
"url": "https://github.com/isaacs/pseudomap/issues"
|
25
|
+
},
|
26
|
+
"dependencies": {},
|
27
|
+
"description": "A thing that is a lot like ES6 `Map`, but without iterators, for use in environments where `for..of` syntax and `Map` are not available.",
|
28
|
+
"devDependencies": {
|
29
|
+
"tap": "^2.3.1"
|
30
|
+
},
|
31
|
+
"directories": {
|
32
|
+
"test": "test"
|
33
|
+
},
|
34
|
+
"dist": {
|
35
|
+
"shasum": "f052a28da70e618917ef0a8ac34c1ae5a68286b3",
|
36
|
+
"tarball": "http://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz"
|
37
|
+
},
|
38
|
+
"gitHead": "b6dc728207a0321ede6479e34506d3e0e13a940b",
|
39
|
+
"homepage": "https://github.com/isaacs/pseudomap#readme",
|
40
|
+
"license": "ISC",
|
41
|
+
"main": "map.js",
|
42
|
+
"maintainers": [
|
43
|
+
{
|
44
|
+
"name": "isaacs",
|
45
|
+
"email": "i@izs.me"
|
46
|
+
}
|
47
|
+
],
|
48
|
+
"name": "pseudomap",
|
49
|
+
"optionalDependencies": {},
|
50
|
+
"readme": "ERROR: No README data found!",
|
51
|
+
"repository": {
|
52
|
+
"type": "git",
|
53
|
+
"url": "git+https://github.com/isaacs/pseudomap.git"
|
54
|
+
},
|
55
|
+
"scripts": {
|
56
|
+
"test": "tap test/*.js"
|
57
|
+
},
|
58
|
+
"version": "1.0.2"
|
59
|
+
}
|
@@ -0,0 +1,113 @@
|
|
1
|
+
var hasOwnProperty = Object.prototype.hasOwnProperty
|
2
|
+
|
3
|
+
module.exports = PseudoMap
|
4
|
+
|
5
|
+
function PseudoMap (set) {
|
6
|
+
if (!(this instanceof PseudoMap)) // whyyyyyyy
|
7
|
+
throw new TypeError("Constructor PseudoMap requires 'new'")
|
8
|
+
|
9
|
+
this.clear()
|
10
|
+
|
11
|
+
if (set) {
|
12
|
+
if ((set instanceof PseudoMap) ||
|
13
|
+
(typeof Map === 'function' && set instanceof Map))
|
14
|
+
set.forEach(function (value, key) {
|
15
|
+
this.set(key, value)
|
16
|
+
}, this)
|
17
|
+
else if (Array.isArray(set))
|
18
|
+
set.forEach(function (kv) {
|
19
|
+
this.set(kv[0], kv[1])
|
20
|
+
}, this)
|
21
|
+
else
|
22
|
+
throw new TypeError('invalid argument')
|
23
|
+
}
|
24
|
+
}
|
25
|
+
|
26
|
+
PseudoMap.prototype.forEach = function (fn, thisp) {
|
27
|
+
thisp = thisp || this
|
28
|
+
Object.keys(this._data).forEach(function (k) {
|
29
|
+
if (k !== 'size')
|
30
|
+
fn.call(thisp, this._data[k].value, this._data[k].key)
|
31
|
+
}, this)
|
32
|
+
}
|
33
|
+
|
34
|
+
PseudoMap.prototype.has = function (k) {
|
35
|
+
return !!find(this._data, k)
|
36
|
+
}
|
37
|
+
|
38
|
+
PseudoMap.prototype.get = function (k) {
|
39
|
+
var res = find(this._data, k)
|
40
|
+
return res && res.value
|
41
|
+
}
|
42
|
+
|
43
|
+
PseudoMap.prototype.set = function (k, v) {
|
44
|
+
set(this._data, k, v)
|
45
|
+
}
|
46
|
+
|
47
|
+
PseudoMap.prototype.delete = function (k) {
|
48
|
+
var res = find(this._data, k)
|
49
|
+
if (res) {
|
50
|
+
delete this._data[res._index]
|
51
|
+
this._data.size--
|
52
|
+
}
|
53
|
+
}
|
54
|
+
|
55
|
+
PseudoMap.prototype.clear = function () {
|
56
|
+
var data = Object.create(null)
|
57
|
+
data.size = 0
|
58
|
+
|
59
|
+
Object.defineProperty(this, '_data', {
|
60
|
+
value: data,
|
61
|
+
enumerable: false,
|
62
|
+
configurable: true,
|
63
|
+
writable: false
|
64
|
+
})
|
65
|
+
}
|
66
|
+
|
67
|
+
Object.defineProperty(PseudoMap.prototype, 'size', {
|
68
|
+
get: function () {
|
69
|
+
return this._data.size
|
70
|
+
},
|
71
|
+
set: function (n) {},
|
72
|
+
enumerable: true,
|
73
|
+
configurable: true
|
74
|
+
})
|
75
|
+
|
76
|
+
PseudoMap.prototype.values =
|
77
|
+
PseudoMap.prototype.keys =
|
78
|
+
PseudoMap.prototype.entries = function () {
|
79
|
+
throw new Error('iterators are not implemented in this version')
|
80
|
+
}
|
81
|
+
|
82
|
+
// Either identical, or both NaN
|
83
|
+
function same (a, b) {
|
84
|
+
return a === b || a !== a && b !== b
|
85
|
+
}
|
86
|
+
|
87
|
+
function Entry (k, v, i) {
|
88
|
+
this.key = k
|
89
|
+
this.value = v
|
90
|
+
this._index = i
|
91
|
+
}
|
92
|
+
|
93
|
+
function find (data, k) {
|
94
|
+
for (var i = 0, s = '_' + k, key = s;
|
95
|
+
hasOwnProperty.call(data, key);
|
96
|
+
key = s + i++) {
|
97
|
+
if (same(data[key].key, k))
|
98
|
+
return data[key]
|
99
|
+
}
|
100
|
+
}
|
101
|
+
|
102
|
+
function set (data, k, v) {
|
103
|
+
for (var i = 0, s = '_' + k, key = s;
|
104
|
+
hasOwnProperty.call(data, key);
|
105
|
+
key = s + i++) {
|
106
|
+
if (same(data[key].key, k)) {
|
107
|
+
data[key].value = v
|
108
|
+
return
|
109
|
+
}
|
110
|
+
}
|
111
|
+
data.size++
|
112
|
+
data[key] = new Entry(k, v, key)
|
113
|
+
}
|
@@ -0,0 +1,86 @@
|
|
1
|
+
var t = require('tap')
|
2
|
+
|
3
|
+
process.env.TEST_PSEUDOMAP = 'true'
|
4
|
+
|
5
|
+
var PM = require('../')
|
6
|
+
runTests(PM)
|
7
|
+
|
8
|
+
// if possible, verify that Map also behaves the same way
|
9
|
+
if (typeof Map === 'function')
|
10
|
+
runTests(Map)
|
11
|
+
|
12
|
+
|
13
|
+
function runTests (Map) {
|
14
|
+
t.throws(Map)
|
15
|
+
|
16
|
+
var m = new Map()
|
17
|
+
|
18
|
+
t.equal(m.size, 0)
|
19
|
+
|
20
|
+
m.set(1, '1 string')
|
21
|
+
t.equal(m.get(1), '1 string')
|
22
|
+
t.equal(m.size, 1)
|
23
|
+
m.size = 1000
|
24
|
+
t.equal(m.size, 1)
|
25
|
+
m.size = 0
|
26
|
+
t.equal(m.size, 1)
|
27
|
+
|
28
|
+
m = new Map([[1, 'number 1'], ['1', 'string 1']])
|
29
|
+
t.equal(m.get(1), 'number 1')
|
30
|
+
t.equal(m.get('1'), 'string 1')
|
31
|
+
t.equal(m.size, 2)
|
32
|
+
|
33
|
+
m = new Map(m)
|
34
|
+
t.equal(m.get(1), 'number 1')
|
35
|
+
t.equal(m.get('1'), 'string 1')
|
36
|
+
t.equal(m.size, 2)
|
37
|
+
|
38
|
+
var akey = {}
|
39
|
+
var bkey = {}
|
40
|
+
m.set(akey, { some: 'data' })
|
41
|
+
m.set(bkey, { some: 'other data' })
|
42
|
+
t.same(m.get(akey), { some: 'data' })
|
43
|
+
t.same(m.get(bkey), { some: 'other data' })
|
44
|
+
t.equal(m.size, 4)
|
45
|
+
|
46
|
+
var x = /x/
|
47
|
+
var y = /x/
|
48
|
+
m.set(x, 'x regex')
|
49
|
+
m.set(y, 'y regex')
|
50
|
+
t.equal(m.get(x), 'x regex')
|
51
|
+
m.set(x, 'x again')
|
52
|
+
t.equal(m.get(x), 'x again')
|
53
|
+
t.equal(m.size, 6)
|
54
|
+
|
55
|
+
m.set(NaN, 'not a number')
|
56
|
+
t.equal(m.get(NaN), 'not a number')
|
57
|
+
m.set(NaN, 'it is a ' + typeof NaN)
|
58
|
+
t.equal(m.get(NaN), 'it is a number')
|
59
|
+
m.set('NaN', 'stringie nan')
|
60
|
+
t.equal(m.get(NaN), 'it is a number')
|
61
|
+
t.equal(m.get('NaN'), 'stringie nan')
|
62
|
+
t.equal(m.size, 8)
|
63
|
+
|
64
|
+
m.delete(NaN)
|
65
|
+
t.equal(m.get(NaN), undefined)
|
66
|
+
t.equal(m.size, 7)
|
67
|
+
|
68
|
+
var expect = [
|
69
|
+
{ value: 'number 1', key: 1 },
|
70
|
+
{ value: 'string 1', key: '1' },
|
71
|
+
{ value: { some: 'data' }, key: {} },
|
72
|
+
{ value: { some: 'other data' }, key: {} },
|
73
|
+
{ value: 'x again', key: /x/ },
|
74
|
+
{ value: 'y regex', key: /x/ },
|
75
|
+
{ value: 'stringie nan', key: 'NaN' }
|
76
|
+
]
|
77
|
+
var actual = []
|
78
|
+
|
79
|
+
m.forEach(function (value, key) {
|
80
|
+
actual.push({ value: value, key: key })
|
81
|
+
})
|
82
|
+
t.same(actual, expect)
|
83
|
+
|
84
|
+
m.clear()
|
85
|
+
t.equal(m.size, 0)
|
86
|
+
}
|
@@ -0,0 +1,15 @@
|
|
1
|
+
The ISC License
|
2
|
+
|
3
|
+
Copyright (c) Isaac Z. Schlueter and Contributors
|
4
|
+
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
6
|
+
purpose with or without fee is hereby granted, provided that the above
|
7
|
+
copyright notice and this permission notice appear in all copies.
|
8
|
+
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
10
|
+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
11
|
+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
12
|
+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
13
|
+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
14
|
+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
15
|
+
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
@@ -0,0 +1,204 @@
|
|
1
|
+
# yallist
|
2
|
+
|
3
|
+
Yet Another Linked List
|
4
|
+
|
5
|
+
There are many doubly-linked list implementations like it, but this
|
6
|
+
one is mine.
|
7
|
+
|
8
|
+
For when an array would be too big, and a Map can't be iterated in
|
9
|
+
reverse order.
|
10
|
+
|
11
|
+
|
12
|
+
[](https://travis-ci.org/isaacs/yallist) [](https://coveralls.io/github/isaacs/yallist)
|
13
|
+
|
14
|
+
## basic usage
|
15
|
+
|
16
|
+
```javascript
|
17
|
+
var yallist = require('yallist')
|
18
|
+
var myList = yallist.create([1, 2, 3])
|
19
|
+
myList.push('foo')
|
20
|
+
myList.unshift('bar')
|
21
|
+
// of course pop() and shift() are there, too
|
22
|
+
console.log(myList.toArray()) // ['bar', 1, 2, 3, 'foo']
|
23
|
+
myList.forEach(function (k) {
|
24
|
+
// walk the list head to tail
|
25
|
+
})
|
26
|
+
myList.forEachReverse(function (k, index, list) {
|
27
|
+
// walk the list tail to head
|
28
|
+
})
|
29
|
+
var myDoubledList = myList.map(function (k) {
|
30
|
+
return k + k
|
31
|
+
})
|
32
|
+
// now myDoubledList contains ['barbar', 2, 4, 6, 'foofoo']
|
33
|
+
// mapReverse is also a thing
|
34
|
+
var myDoubledListReverse = myList.mapReverse(function (k) {
|
35
|
+
return k + k
|
36
|
+
}) // ['foofoo', 6, 4, 2, 'barbar']
|
37
|
+
|
38
|
+
var reduced = myList.reduce(function (set, entry) {
|
39
|
+
set += entry
|
40
|
+
return set
|
41
|
+
}, 'start')
|
42
|
+
console.log(reduced) // 'startfoo123bar'
|
43
|
+
```
|
44
|
+
|
45
|
+
## api
|
46
|
+
|
47
|
+
The whole API is considered "public".
|
48
|
+
|
49
|
+
Functions with the same name as an Array method work more or less the
|
50
|
+
same way.
|
51
|
+
|
52
|
+
There's reverse versions of most things because that's the point.
|
53
|
+
|
54
|
+
### Yallist
|
55
|
+
|
56
|
+
Default export, the class that holds and manages a list.
|
57
|
+
|
58
|
+
Call it with either a forEach-able (like an array) or a set of
|
59
|
+
arguments, to initialize the list.
|
60
|
+
|
61
|
+
The Array-ish methods all act like you'd expect. No magic length,
|
62
|
+
though, so if you change that it won't automatically prune or add
|
63
|
+
empty spots.
|
64
|
+
|
65
|
+
### Yallist.create(..)
|
66
|
+
|
67
|
+
Alias for Yallist function. Some people like factories.
|
68
|
+
|
69
|
+
#### yallist.head
|
70
|
+
|
71
|
+
The first node in the list
|
72
|
+
|
73
|
+
#### yallist.tail
|
74
|
+
|
75
|
+
The last node in the list
|
76
|
+
|
77
|
+
#### yallist.length
|
78
|
+
|
79
|
+
The number of nodes in the list. (Change this at your peril. It is
|
80
|
+
not magic like Array length.)
|
81
|
+
|
82
|
+
#### yallist.toArray()
|
83
|
+
|
84
|
+
Convert the list to an array.
|
85
|
+
|
86
|
+
#### yallist.forEach(fn, [thisp])
|
87
|
+
|
88
|
+
Call a function on each item in the list.
|
89
|
+
|
90
|
+
#### yallist.forEachReverse(fn, [thisp])
|
91
|
+
|
92
|
+
Call a function on each item in the list, in reverse order.
|
93
|
+
|
94
|
+
#### yallist.get(n)
|
95
|
+
|
96
|
+
Get the data at position `n` in the list. If you use this a lot,
|
97
|
+
probably better off just using an Array.
|
98
|
+
|
99
|
+
#### yallist.getReverse(n)
|
100
|
+
|
101
|
+
Get the data at position `n`, counting from the tail.
|
102
|
+
|
103
|
+
#### yallist.map(fn, thisp)
|
104
|
+
|
105
|
+
Create a new Yallist with the result of calling the function on each
|
106
|
+
item.
|
107
|
+
|
108
|
+
#### yallist.mapReverse(fn, thisp)
|
109
|
+
|
110
|
+
Same as `map`, but in reverse.
|
111
|
+
|
112
|
+
#### yallist.pop()
|
113
|
+
|
114
|
+
Get the data from the list tail, and remove the tail from the list.
|
115
|
+
|
116
|
+
#### yallist.push(item, ...)
|
117
|
+
|
118
|
+
Insert one or more items to the tail of the list.
|
119
|
+
|
120
|
+
#### yallist.reduce(fn, initialValue)
|
121
|
+
|
122
|
+
Like Array.reduce.
|
123
|
+
|
124
|
+
#### yallist.reduceReverse
|
125
|
+
|
126
|
+
Like Array.reduce, but in reverse.
|
127
|
+
|
128
|
+
#### yallist.reverse
|
129
|
+
|
130
|
+
Reverse the list in place.
|
131
|
+
|
132
|
+
#### yallist.shift()
|
133
|
+
|
134
|
+
Get the data from the list head, and remove the head from the list.
|
135
|
+
|
136
|
+
#### yallist.slice([from], [to])
|
137
|
+
|
138
|
+
Just like Array.slice, but returns a new Yallist.
|
139
|
+
|
140
|
+
#### yallist.sliceReverse([from], [to])
|
141
|
+
|
142
|
+
Just like yallist.slice, but the result is returned in reverse.
|
143
|
+
|
144
|
+
#### yallist.toArray()
|
145
|
+
|
146
|
+
Create an array representation of the list.
|
147
|
+
|
148
|
+
#### yallist.toArrayReverse()
|
149
|
+
|
150
|
+
Create a reversed array representation of the list.
|
151
|
+
|
152
|
+
#### yallist.unshift(item, ...)
|
153
|
+
|
154
|
+
Insert one or more items to the head of the list.
|
155
|
+
|
156
|
+
#### yallist.unshiftNode(node)
|
157
|
+
|
158
|
+
Move a Node object to the front of the list. (That is, pull it out of
|
159
|
+
wherever it lives, and make it the new head.)
|
160
|
+
|
161
|
+
If the node belongs to a different list, then that list will remove it
|
162
|
+
first.
|
163
|
+
|
164
|
+
#### yallist.pushNode(node)
|
165
|
+
|
166
|
+
Move a Node object to the end of the list. (That is, pull it out of
|
167
|
+
wherever it lives, and make it the new tail.)
|
168
|
+
|
169
|
+
If the node belongs to a list already, then that list will remove it
|
170
|
+
first.
|
171
|
+
|
172
|
+
#### yallist.removeNode(node)
|
173
|
+
|
174
|
+
Remove a node from the list, preserving referential integrity of head
|
175
|
+
and tail and other nodes.
|
176
|
+
|
177
|
+
Will throw an error if you try to have a list remove a node that
|
178
|
+
doesn't belong to it.
|
179
|
+
|
180
|
+
### Yallist.Node
|
181
|
+
|
182
|
+
The class that holds the data and is actually the list.
|
183
|
+
|
184
|
+
Call with `var n = new Node(value, previousNode, nextNode)`
|
185
|
+
|
186
|
+
Note that if you do direct operations on Nodes themselves, it's very
|
187
|
+
easy to get into weird states where the list is broken. Be careful :)
|
188
|
+
|
189
|
+
#### node.next
|
190
|
+
|
191
|
+
The next node in the list.
|
192
|
+
|
193
|
+
#### node.prev
|
194
|
+
|
195
|
+
The previous node in the list.
|
196
|
+
|
197
|
+
#### node.value
|
198
|
+
|
199
|
+
The data the node contains.
|
200
|
+
|
201
|
+
#### node.list
|
202
|
+
|
203
|
+
The list to which this node belongs. (Null if it does not belong to
|
204
|
+
any list.)
|
@@ -0,0 +1,59 @@
|
|
1
|
+
{
|
2
|
+
"_from": "yallist@^2.0.0",
|
3
|
+
"_id": "yallist@2.0.0",
|
4
|
+
"_location": "/aws4/lru-cache/yallist",
|
5
|
+
"_nodeVersion": "4.0.0",
|
6
|
+
"_npmUser": {
|
7
|
+
"email": "i@izs.me",
|
8
|
+
"name": "isaacs"
|
9
|
+
},
|
10
|
+
"_npmVersion": "3.3.2",
|
11
|
+
"_phantomChildren": {},
|
12
|
+
"_requiredBy": [
|
13
|
+
"/aws4/lru-cache"
|
14
|
+
],
|
15
|
+
"_resolved": "https://registry.npmjs.org/yallist/-/yallist-2.0.0.tgz",
|
16
|
+
"_shasum": "306c543835f09ee1a4cb23b7bce9ab341c91cdd4",
|
17
|
+
"_shrinkwrap": null,
|
18
|
+
"author": {
|
19
|
+
"email": "i@izs.me",
|
20
|
+
"name": "Isaac Z. Schlueter",
|
21
|
+
"url": "http://blog.izs.me/"
|
22
|
+
},
|
23
|
+
"bugs": {
|
24
|
+
"url": "https://github.com/isaacs/yallist/issues"
|
25
|
+
},
|
26
|
+
"dependencies": {},
|
27
|
+
"description": "Yet Another Linked List",
|
28
|
+
"devDependencies": {
|
29
|
+
"tap": "^2.3.2"
|
30
|
+
},
|
31
|
+
"directories": {
|
32
|
+
"test": "test"
|
33
|
+
},
|
34
|
+
"dist": {
|
35
|
+
"shasum": "306c543835f09ee1a4cb23b7bce9ab341c91cdd4",
|
36
|
+
"tarball": "http://registry.npmjs.org/yallist/-/yallist-2.0.0.tgz"
|
37
|
+
},
|
38
|
+
"gitHead": "702eaba87deefa9f8fc2f8e36cb225bc2141fdc3",
|
39
|
+
"homepage": "https://github.com/isaacs/yallist#readme",
|
40
|
+
"license": "ISC",
|
41
|
+
"main": "yallist.js",
|
42
|
+
"maintainers": [
|
43
|
+
{
|
44
|
+
"name": "isaacs",
|
45
|
+
"email": "i@izs.me"
|
46
|
+
}
|
47
|
+
],
|
48
|
+
"name": "yallist",
|
49
|
+
"optionalDependencies": {},
|
50
|
+
"readme": "ERROR: No README data found!",
|
51
|
+
"repository": {
|
52
|
+
"type": "git",
|
53
|
+
"url": "git+https://github.com/isaacs/yallist.git"
|
54
|
+
},
|
55
|
+
"scripts": {
|
56
|
+
"test": "tap test/*.js --cov"
|
57
|
+
},
|
58
|
+
"version": "2.0.0"
|
59
|
+
}
|