govuk_publishing_components 17.20.0 → 17.21.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/stylesheets/govuk_publishing_components/components/_select.scss +8 -0
- data/app/views/govuk_publishing_components/components/_subscription-links.html.erb +15 -5
- data/app/views/govuk_publishing_components/components/docs/subscription-links.yml +13 -2
- data/lib/govuk_publishing_components/version.rb +1 -1
- data/node_modules/accessible-autocomplete/package.json +1 -1
- data/node_modules/graceful-fs/package.json +13 -13
- data/node_modules/graceful-fs/polyfills.js +17 -11
- data/node_modules/hosted-git-info/CHANGELOG.md +40 -0
- data/node_modules/hosted-git-info/git-host-info.js +5 -3
- data/node_modules/hosted-git-info/git-host.js +35 -10
- data/node_modules/hosted-git-info/index.js +17 -15
- data/node_modules/hosted-git-info/package.json +40 -30
- data/node_modules/lru-cache/LICENSE +15 -0
- data/node_modules/lru-cache/README.md +166 -0
- data/node_modules/lru-cache/index.js +334 -0
- data/node_modules/lru-cache/package.json +108 -0
- data/node_modules/pkg-conf/package.json +1 -1
- data/node_modules/preact/debug.js +630 -2
- data/node_modules/preact/debug.js.map +1 -1
- data/node_modules/preact/debug/dist/debug.js +2 -0
- data/node_modules/preact/debug/dist/debug.js.map +1 -0
- data/node_modules/preact/debug/dist/debug.mjs +681 -0
- data/node_modules/preact/debug/dist/debug.mjs.map +1 -0
- data/node_modules/preact/debug/dist/debug.module.js +2 -0
- data/node_modules/preact/debug/dist/debug.module.js.map +1 -0
- data/node_modules/preact/debug/dist/debug.umd.js +2 -0
- data/node_modules/preact/debug/dist/debug.umd.js.map +1 -0
- data/node_modules/preact/debug/index.js +2 -1
- data/node_modules/preact/dist/preact.d.ts +808 -3
- data/node_modules/preact/dist/preact.dev.js +727 -727
- data/node_modules/preact/dist/preact.dev.js.map +1 -1
- data/node_modules/preact/dist/preact.js +1 -1
- data/node_modules/preact/dist/preact.js.flow +3 -3
- data/node_modules/preact/dist/preact.js.map +1 -1
- data/node_modules/preact/dist/preact.min.js +1 -1
- data/node_modules/preact/dist/preact.min.js.map +1 -1
- data/node_modules/preact/dist/preact.mjs +724 -724
- data/node_modules/preact/dist/preact.mjs.map +1 -1
- data/node_modules/preact/dist/preact.umd.js +751 -0
- data/node_modules/preact/dist/preact.umd.js.map +1 -0
- data/node_modules/preact/package.json +43 -26
- data/node_modules/preact/src/preact.d.ts +808 -3
- data/node_modules/preact/src/preact.js.flow +3 -3
- data/node_modules/preact/src/util.js +1 -1
- data/node_modules/yallist/LICENSE +15 -0
- data/node_modules/yallist/README.md +204 -0
- data/node_modules/yallist/iterator.js +8 -0
- data/node_modules/yallist/package.json +97 -0
- data/node_modules/yallist/yallist.js +376 -0
- metadata +21 -2
@@ -1,13 +1,13 @@
|
|
1
1
|
/* @flow */
|
2
2
|
|
3
|
-
import { createElement, cloneElement, Component, type Node } from 'react';
|
3
|
+
import { createElement, cloneElement, createRef, Component, type Node } from 'react';
|
4
4
|
|
5
5
|
declare var h: typeof createElement;
|
6
6
|
|
7
7
|
declare function render(vnode: Node, parent: Element, toReplace?: Element): Element;
|
8
8
|
|
9
|
-
export { h, createElement, cloneElement, Component, render };
|
10
|
-
export default { h, createElement, cloneElement, Component, render };
|
9
|
+
export { h, createElement, cloneElement, createRef, Component, render };
|
10
|
+
export default { h, createElement, cloneElement, createRef, Component, render };
|
11
11
|
|
12
12
|
declare type VNode<P> = {
|
13
13
|
nodeName: string | Function,
|
@@ -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
|
+
[![Build Status](https://travis-ci.org/isaacs/yallist.svg?branch=master)](https://travis-ci.org/isaacs/yallist) [![Coverage Status](https://coveralls.io/repos/isaacs/yallist/badge.svg?service=github)](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,97 @@
|
|
1
|
+
{
|
2
|
+
"_args": [
|
3
|
+
[
|
4
|
+
{
|
5
|
+
"raw": "yallist@^3.0.2",
|
6
|
+
"scope": null,
|
7
|
+
"escapedName": "yallist",
|
8
|
+
"name": "yallist",
|
9
|
+
"rawSpec": "^3.0.2",
|
10
|
+
"spec": ">=3.0.2 <4.0.0",
|
11
|
+
"type": "range"
|
12
|
+
},
|
13
|
+
"/var/lib/jenkins/workspace/ublishing_components_master-N4FWJIUY4CIFHKGZOAAEVVXODRY3YBORQOPIBBXWX72VUPSGJRRQ/node_modules/lru-cache"
|
14
|
+
]
|
15
|
+
],
|
16
|
+
"_from": "yallist@>=3.0.2 <4.0.0",
|
17
|
+
"_hasShrinkwrap": false,
|
18
|
+
"_id": "yallist@3.0.3",
|
19
|
+
"_inCache": true,
|
20
|
+
"_location": "/yallist",
|
21
|
+
"_nodeVersion": "10.12.0",
|
22
|
+
"_npmOperationalInternal": {
|
23
|
+
"host": "s3://npm-registry-packages",
|
24
|
+
"tmp": "tmp/yallist_3.0.3_1542842556417_0.767908228373708"
|
25
|
+
},
|
26
|
+
"_npmUser": {
|
27
|
+
"name": "isaacs",
|
28
|
+
"email": "i@izs.me"
|
29
|
+
},
|
30
|
+
"_npmVersion": "6.4.1",
|
31
|
+
"_phantomChildren": {},
|
32
|
+
"_requested": {
|
33
|
+
"raw": "yallist@^3.0.2",
|
34
|
+
"scope": null,
|
35
|
+
"escapedName": "yallist",
|
36
|
+
"name": "yallist",
|
37
|
+
"rawSpec": "^3.0.2",
|
38
|
+
"spec": ">=3.0.2 <4.0.0",
|
39
|
+
"type": "range"
|
40
|
+
},
|
41
|
+
"_requiredBy": [
|
42
|
+
"/lru-cache"
|
43
|
+
],
|
44
|
+
"_resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.3.tgz",
|
45
|
+
"_shasum": "b4b049e314be545e3ce802236d6cd22cd91c3de9",
|
46
|
+
"_shrinkwrap": null,
|
47
|
+
"_spec": "yallist@^3.0.2",
|
48
|
+
"_where": "/var/lib/jenkins/workspace/ublishing_components_master-N4FWJIUY4CIFHKGZOAAEVVXODRY3YBORQOPIBBXWX72VUPSGJRRQ/node_modules/lru-cache",
|
49
|
+
"author": {
|
50
|
+
"name": "Isaac Z. Schlueter",
|
51
|
+
"email": "i@izs.me",
|
52
|
+
"url": "http://blog.izs.me/"
|
53
|
+
},
|
54
|
+
"bugs": {
|
55
|
+
"url": "https://github.com/isaacs/yallist/issues"
|
56
|
+
},
|
57
|
+
"dependencies": {},
|
58
|
+
"description": "Yet Another Linked List",
|
59
|
+
"devDependencies": {
|
60
|
+
"tap": "^12.1.0"
|
61
|
+
},
|
62
|
+
"directories": {
|
63
|
+
"test": "test"
|
64
|
+
},
|
65
|
+
"dist": {
|
66
|
+
"integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==",
|
67
|
+
"shasum": "b4b049e314be545e3ce802236d6cd22cd91c3de9",
|
68
|
+
"tarball": "https://registry.npmjs.org/yallist/-/yallist-3.0.3.tgz",
|
69
|
+
"fileCount": 5,
|
70
|
+
"unpackedSize": 13744,
|
71
|
+
"npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJb9ei9CRA9TVsSAnZWagAA9zIP/ijnxiQ7otRl2x3s1hy3\nzi7QbMsTJzIafuxtZNPxIctL9ePQkyl5ccfvAGamlNDJKaWZZocHfCghCaCw\n//TLvHHISid3zVbs6iYiy/xGP45UFbRf+4/qEmBE5JVV9ZHyjwaNDwf19HQ5\n3Lcfofdwo3kkR/xIWsYA2S2vmkdwviPYPWsPMwyQIGmCnEV61WUuuvedXA5m\nBd5W6l6ofe8qGQPQVaniEFaqViUZlNxSyiwSiKcUNve0sWvT0BVr9QmvpDFi\nmcGrYbcUhMNtxexdUDdJ4QB0BNLEPymm2iCB2iaq+WZiZcCShDFl1M9PJKdB\nNQsKddC1xTfWfdtIbtw0rQDwBOYJpw5sFFnurCaAz2/JNEaYZSqxwzwgud0s\nh7/AaTV/1Knpk0qEXskogYMej8kO4AIcel4iFINxlIy+5yDWHcThEm2aMDNZ\n63wRojSH/crwKdFYAwVxCUTRQGcLre/0NqNIL9F6cPZI/JmzzG+nfp6UEf7K\n6E8zeY7xPf6fJ2KmKyP8nq6rNY50JexlLwY30LZY9g9shaPBQ9lAUSTaIBvN\n3oDin3U7V/+Reqlw8tSOtjOUP1sqSP66Wv8Z0NfWUgv1jStv0cduD1rAvMHE\nCD2VxLsFsl1rv8uGuW7NfNkcrBtqp7oFGsoBDAeHVUCjRh5ZDrZdmbY7zabD\n2S3K\r\n=UzPp\r\n-----END PGP SIGNATURE-----\r\n"
|
72
|
+
},
|
73
|
+
"gitHead": "47ab1ce288032985c90ee568681b35ad8978be41",
|
74
|
+
"homepage": "https://github.com/isaacs/yallist#readme",
|
75
|
+
"license": "ISC",
|
76
|
+
"main": "yallist.js",
|
77
|
+
"maintainers": [
|
78
|
+
{
|
79
|
+
"name": "isaacs",
|
80
|
+
"email": "i@izs.me"
|
81
|
+
}
|
82
|
+
],
|
83
|
+
"name": "yallist",
|
84
|
+
"optionalDependencies": {},
|
85
|
+
"readme": "ERROR: No README data found!",
|
86
|
+
"repository": {
|
87
|
+
"type": "git",
|
88
|
+
"url": "git+https://github.com/isaacs/yallist.git"
|
89
|
+
},
|
90
|
+
"scripts": {
|
91
|
+
"postpublish": "git push origin --all; git push origin --tags",
|
92
|
+
"postversion": "npm publish",
|
93
|
+
"preversion": "npm test",
|
94
|
+
"test": "tap test/*.js --100"
|
95
|
+
},
|
96
|
+
"version": "3.0.3"
|
97
|
+
}
|
@@ -0,0 +1,376 @@
|
|
1
|
+
'use strict'
|
2
|
+
module.exports = Yallist
|
3
|
+
|
4
|
+
Yallist.Node = Node
|
5
|
+
Yallist.create = Yallist
|
6
|
+
|
7
|
+
function Yallist (list) {
|
8
|
+
var self = this
|
9
|
+
if (!(self instanceof Yallist)) {
|
10
|
+
self = new Yallist()
|
11
|
+
}
|
12
|
+
|
13
|
+
self.tail = null
|
14
|
+
self.head = null
|
15
|
+
self.length = 0
|
16
|
+
|
17
|
+
if (list && typeof list.forEach === 'function') {
|
18
|
+
list.forEach(function (item) {
|
19
|
+
self.push(item)
|
20
|
+
})
|
21
|
+
} else if (arguments.length > 0) {
|
22
|
+
for (var i = 0, l = arguments.length; i < l; i++) {
|
23
|
+
self.push(arguments[i])
|
24
|
+
}
|
25
|
+
}
|
26
|
+
|
27
|
+
return self
|
28
|
+
}
|
29
|
+
|
30
|
+
Yallist.prototype.removeNode = function (node) {
|
31
|
+
if (node.list !== this) {
|
32
|
+
throw new Error('removing node which does not belong to this list')
|
33
|
+
}
|
34
|
+
|
35
|
+
var next = node.next
|
36
|
+
var prev = node.prev
|
37
|
+
|
38
|
+
if (next) {
|
39
|
+
next.prev = prev
|
40
|
+
}
|
41
|
+
|
42
|
+
if (prev) {
|
43
|
+
prev.next = next
|
44
|
+
}
|
45
|
+
|
46
|
+
if (node === this.head) {
|
47
|
+
this.head = next
|
48
|
+
}
|
49
|
+
if (node === this.tail) {
|
50
|
+
this.tail = prev
|
51
|
+
}
|
52
|
+
|
53
|
+
node.list.length--
|
54
|
+
node.next = null
|
55
|
+
node.prev = null
|
56
|
+
node.list = null
|
57
|
+
}
|
58
|
+
|
59
|
+
Yallist.prototype.unshiftNode = function (node) {
|
60
|
+
if (node === this.head) {
|
61
|
+
return
|
62
|
+
}
|
63
|
+
|
64
|
+
if (node.list) {
|
65
|
+
node.list.removeNode(node)
|
66
|
+
}
|
67
|
+
|
68
|
+
var head = this.head
|
69
|
+
node.list = this
|
70
|
+
node.next = head
|
71
|
+
if (head) {
|
72
|
+
head.prev = node
|
73
|
+
}
|
74
|
+
|
75
|
+
this.head = node
|
76
|
+
if (!this.tail) {
|
77
|
+
this.tail = node
|
78
|
+
}
|
79
|
+
this.length++
|
80
|
+
}
|
81
|
+
|
82
|
+
Yallist.prototype.pushNode = function (node) {
|
83
|
+
if (node === this.tail) {
|
84
|
+
return
|
85
|
+
}
|
86
|
+
|
87
|
+
if (node.list) {
|
88
|
+
node.list.removeNode(node)
|
89
|
+
}
|
90
|
+
|
91
|
+
var tail = this.tail
|
92
|
+
node.list = this
|
93
|
+
node.prev = tail
|
94
|
+
if (tail) {
|
95
|
+
tail.next = node
|
96
|
+
}
|
97
|
+
|
98
|
+
this.tail = node
|
99
|
+
if (!this.head) {
|
100
|
+
this.head = node
|
101
|
+
}
|
102
|
+
this.length++
|
103
|
+
}
|
104
|
+
|
105
|
+
Yallist.prototype.push = function () {
|
106
|
+
for (var i = 0, l = arguments.length; i < l; i++) {
|
107
|
+
push(this, arguments[i])
|
108
|
+
}
|
109
|
+
return this.length
|
110
|
+
}
|
111
|
+
|
112
|
+
Yallist.prototype.unshift = function () {
|
113
|
+
for (var i = 0, l = arguments.length; i < l; i++) {
|
114
|
+
unshift(this, arguments[i])
|
115
|
+
}
|
116
|
+
return this.length
|
117
|
+
}
|
118
|
+
|
119
|
+
Yallist.prototype.pop = function () {
|
120
|
+
if (!this.tail) {
|
121
|
+
return undefined
|
122
|
+
}
|
123
|
+
|
124
|
+
var res = this.tail.value
|
125
|
+
this.tail = this.tail.prev
|
126
|
+
if (this.tail) {
|
127
|
+
this.tail.next = null
|
128
|
+
} else {
|
129
|
+
this.head = null
|
130
|
+
}
|
131
|
+
this.length--
|
132
|
+
return res
|
133
|
+
}
|
134
|
+
|
135
|
+
Yallist.prototype.shift = function () {
|
136
|
+
if (!this.head) {
|
137
|
+
return undefined
|
138
|
+
}
|
139
|
+
|
140
|
+
var res = this.head.value
|
141
|
+
this.head = this.head.next
|
142
|
+
if (this.head) {
|
143
|
+
this.head.prev = null
|
144
|
+
} else {
|
145
|
+
this.tail = null
|
146
|
+
}
|
147
|
+
this.length--
|
148
|
+
return res
|
149
|
+
}
|
150
|
+
|
151
|
+
Yallist.prototype.forEach = function (fn, thisp) {
|
152
|
+
thisp = thisp || this
|
153
|
+
for (var walker = this.head, i = 0; walker !== null; i++) {
|
154
|
+
fn.call(thisp, walker.value, i, this)
|
155
|
+
walker = walker.next
|
156
|
+
}
|
157
|
+
}
|
158
|
+
|
159
|
+
Yallist.prototype.forEachReverse = function (fn, thisp) {
|
160
|
+
thisp = thisp || this
|
161
|
+
for (var walker = this.tail, i = this.length - 1; walker !== null; i--) {
|
162
|
+
fn.call(thisp, walker.value, i, this)
|
163
|
+
walker = walker.prev
|
164
|
+
}
|
165
|
+
}
|
166
|
+
|
167
|
+
Yallist.prototype.get = function (n) {
|
168
|
+
for (var i = 0, walker = this.head; walker !== null && i < n; i++) {
|
169
|
+
// abort out of the list early if we hit a cycle
|
170
|
+
walker = walker.next
|
171
|
+
}
|
172
|
+
if (i === n && walker !== null) {
|
173
|
+
return walker.value
|
174
|
+
}
|
175
|
+
}
|
176
|
+
|
177
|
+
Yallist.prototype.getReverse = function (n) {
|
178
|
+
for (var i = 0, walker = this.tail; walker !== null && i < n; i++) {
|
179
|
+
// abort out of the list early if we hit a cycle
|
180
|
+
walker = walker.prev
|
181
|
+
}
|
182
|
+
if (i === n && walker !== null) {
|
183
|
+
return walker.value
|
184
|
+
}
|
185
|
+
}
|
186
|
+
|
187
|
+
Yallist.prototype.map = function (fn, thisp) {
|
188
|
+
thisp = thisp || this
|
189
|
+
var res = new Yallist()
|
190
|
+
for (var walker = this.head; walker !== null;) {
|
191
|
+
res.push(fn.call(thisp, walker.value, this))
|
192
|
+
walker = walker.next
|
193
|
+
}
|
194
|
+
return res
|
195
|
+
}
|
196
|
+
|
197
|
+
Yallist.prototype.mapReverse = function (fn, thisp) {
|
198
|
+
thisp = thisp || this
|
199
|
+
var res = new Yallist()
|
200
|
+
for (var walker = this.tail; walker !== null;) {
|
201
|
+
res.push(fn.call(thisp, walker.value, this))
|
202
|
+
walker = walker.prev
|
203
|
+
}
|
204
|
+
return res
|
205
|
+
}
|
206
|
+
|
207
|
+
Yallist.prototype.reduce = function (fn, initial) {
|
208
|
+
var acc
|
209
|
+
var walker = this.head
|
210
|
+
if (arguments.length > 1) {
|
211
|
+
acc = initial
|
212
|
+
} else if (this.head) {
|
213
|
+
walker = this.head.next
|
214
|
+
acc = this.head.value
|
215
|
+
} else {
|
216
|
+
throw new TypeError('Reduce of empty list with no initial value')
|
217
|
+
}
|
218
|
+
|
219
|
+
for (var i = 0; walker !== null; i++) {
|
220
|
+
acc = fn(acc, walker.value, i)
|
221
|
+
walker = walker.next
|
222
|
+
}
|
223
|
+
|
224
|
+
return acc
|
225
|
+
}
|
226
|
+
|
227
|
+
Yallist.prototype.reduceReverse = function (fn, initial) {
|
228
|
+
var acc
|
229
|
+
var walker = this.tail
|
230
|
+
if (arguments.length > 1) {
|
231
|
+
acc = initial
|
232
|
+
} else if (this.tail) {
|
233
|
+
walker = this.tail.prev
|
234
|
+
acc = this.tail.value
|
235
|
+
} else {
|
236
|
+
throw new TypeError('Reduce of empty list with no initial value')
|
237
|
+
}
|
238
|
+
|
239
|
+
for (var i = this.length - 1; walker !== null; i--) {
|
240
|
+
acc = fn(acc, walker.value, i)
|
241
|
+
walker = walker.prev
|
242
|
+
}
|
243
|
+
|
244
|
+
return acc
|
245
|
+
}
|
246
|
+
|
247
|
+
Yallist.prototype.toArray = function () {
|
248
|
+
var arr = new Array(this.length)
|
249
|
+
for (var i = 0, walker = this.head; walker !== null; i++) {
|
250
|
+
arr[i] = walker.value
|
251
|
+
walker = walker.next
|
252
|
+
}
|
253
|
+
return arr
|
254
|
+
}
|
255
|
+
|
256
|
+
Yallist.prototype.toArrayReverse = function () {
|
257
|
+
var arr = new Array(this.length)
|
258
|
+
for (var i = 0, walker = this.tail; walker !== null; i++) {
|
259
|
+
arr[i] = walker.value
|
260
|
+
walker = walker.prev
|
261
|
+
}
|
262
|
+
return arr
|
263
|
+
}
|
264
|
+
|
265
|
+
Yallist.prototype.slice = function (from, to) {
|
266
|
+
to = to || this.length
|
267
|
+
if (to < 0) {
|
268
|
+
to += this.length
|
269
|
+
}
|
270
|
+
from = from || 0
|
271
|
+
if (from < 0) {
|
272
|
+
from += this.length
|
273
|
+
}
|
274
|
+
var ret = new Yallist()
|
275
|
+
if (to < from || to < 0) {
|
276
|
+
return ret
|
277
|
+
}
|
278
|
+
if (from < 0) {
|
279
|
+
from = 0
|
280
|
+
}
|
281
|
+
if (to > this.length) {
|
282
|
+
to = this.length
|
283
|
+
}
|
284
|
+
for (var i = 0, walker = this.head; walker !== null && i < from; i++) {
|
285
|
+
walker = walker.next
|
286
|
+
}
|
287
|
+
for (; walker !== null && i < to; i++, walker = walker.next) {
|
288
|
+
ret.push(walker.value)
|
289
|
+
}
|
290
|
+
return ret
|
291
|
+
}
|
292
|
+
|
293
|
+
Yallist.prototype.sliceReverse = function (from, to) {
|
294
|
+
to = to || this.length
|
295
|
+
if (to < 0) {
|
296
|
+
to += this.length
|
297
|
+
}
|
298
|
+
from = from || 0
|
299
|
+
if (from < 0) {
|
300
|
+
from += this.length
|
301
|
+
}
|
302
|
+
var ret = new Yallist()
|
303
|
+
if (to < from || to < 0) {
|
304
|
+
return ret
|
305
|
+
}
|
306
|
+
if (from < 0) {
|
307
|
+
from = 0
|
308
|
+
}
|
309
|
+
if (to > this.length) {
|
310
|
+
to = this.length
|
311
|
+
}
|
312
|
+
for (var i = this.length, walker = this.tail; walker !== null && i > to; i--) {
|
313
|
+
walker = walker.prev
|
314
|
+
}
|
315
|
+
for (; walker !== null && i > from; i--, walker = walker.prev) {
|
316
|
+
ret.push(walker.value)
|
317
|
+
}
|
318
|
+
return ret
|
319
|
+
}
|
320
|
+
|
321
|
+
Yallist.prototype.reverse = function () {
|
322
|
+
var head = this.head
|
323
|
+
var tail = this.tail
|
324
|
+
for (var walker = head; walker !== null; walker = walker.prev) {
|
325
|
+
var p = walker.prev
|
326
|
+
walker.prev = walker.next
|
327
|
+
walker.next = p
|
328
|
+
}
|
329
|
+
this.head = tail
|
330
|
+
this.tail = head
|
331
|
+
return this
|
332
|
+
}
|
333
|
+
|
334
|
+
function push (self, item) {
|
335
|
+
self.tail = new Node(item, self.tail, null, self)
|
336
|
+
if (!self.head) {
|
337
|
+
self.head = self.tail
|
338
|
+
}
|
339
|
+
self.length++
|
340
|
+
}
|
341
|
+
|
342
|
+
function unshift (self, item) {
|
343
|
+
self.head = new Node(item, null, self.head, self)
|
344
|
+
if (!self.tail) {
|
345
|
+
self.tail = self.head
|
346
|
+
}
|
347
|
+
self.length++
|
348
|
+
}
|
349
|
+
|
350
|
+
function Node (value, prev, next, list) {
|
351
|
+
if (!(this instanceof Node)) {
|
352
|
+
return new Node(value, prev, next, list)
|
353
|
+
}
|
354
|
+
|
355
|
+
this.list = list
|
356
|
+
this.value = value
|
357
|
+
|
358
|
+
if (prev) {
|
359
|
+
prev.next = this
|
360
|
+
this.prev = prev
|
361
|
+
} else {
|
362
|
+
this.prev = null
|
363
|
+
}
|
364
|
+
|
365
|
+
if (next) {
|
366
|
+
next.prev = this
|
367
|
+
this.next = next
|
368
|
+
} else {
|
369
|
+
this.next = null
|
370
|
+
}
|
371
|
+
}
|
372
|
+
|
373
|
+
try {
|
374
|
+
// add if support for Symbol.iterator is present
|
375
|
+
require('./iterator.js')(Yallist)
|
376
|
+
} catch (er) {}
|