atomic-fns 0.3.3 → 0.3.5

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.
Files changed (48) hide show
  1. package/README.md +18 -4
  2. package/core/collections/LRUCache.d.ts +22 -1
  3. package/core/collections/LRUCache.js +22 -1
  4. package/core/collections/LRUCache.ts +22 -1
  5. package/core/collections/SortedMap.d.ts +1 -1
  6. package/core/collections/SortedMap.js +1 -1
  7. package/core/collections/SortedMap.ts +1 -1
  8. package/core/collections/SortedSet.d.ts +6 -0
  9. package/core/collections/SortedSet.js +6 -0
  10. package/core/collections/SortedSet.ts +6 -0
  11. package/core/collections/SortedTree.d.ts +3 -3
  12. package/core/collections/SortedTree.js +3 -3
  13. package/core/collections/SortedTree.ts +3 -3
  14. package/core/collections/abc.d.ts +1 -1
  15. package/core/collections/abc.ts +1 -1
  16. package/core/collections/deque.d.ts +55 -48
  17. package/core/collections/deque.js +61 -53
  18. package/core/collections/deque.ts +63 -54
  19. package/core/collections/index.d.ts +2 -0
  20. package/core/collections/index.js +7 -5
  21. package/core/collections/index.ts +7 -5
  22. package/core/functools/index.d.ts +3 -2
  23. package/core/functools/index.ts +8 -3
  24. package/core/globals/index.d.ts +23 -4
  25. package/core/globals/index.js +29 -6
  26. package/core/globals/index.ts +40 -7
  27. package/core/i18n/date/format.d.ts +16 -0
  28. package/core/i18n/date/format.js +307 -0
  29. package/core/i18n/date/format.ts +343 -0
  30. package/core/i18n/date/index.d.ts +224 -0
  31. package/core/i18n/date/index.js +387 -0
  32. package/core/i18n/date/index.ts +471 -0
  33. package/core/i18n/date/test.html +67 -0
  34. package/core/i18n/index.d.ts +7 -0
  35. package/core/i18n/index.js +7 -0
  36. package/core/i18n/index.ts +8 -0
  37. package/core/index.d.ts +1 -0
  38. package/core/index.js +1 -0
  39. package/core/index.ts +1 -0
  40. package/core/operators/index.d.ts +1 -1
  41. package/core/operators/index.js +35 -5
  42. package/core/operators/index.ts +34 -6
  43. package/package.json +11 -11
  44. package/tests/globals.spec.ts +12 -12
  45. package/tsconfig.json +2 -1
  46. package/core/datetime/index.d.ts +0 -45
  47. package/core/datetime/index.js +0 -71
  48. package/core/datetime/index.ts +0 -128
package/README.md CHANGED
@@ -21,7 +21,7 @@ You may prefer this because it's:
21
21
 
22
22
  ## Get Started
23
23
 
24
- This library is available as an npm package.
24
+ This library is available as an [npm package](https://www.npmjs.com/package/atomic-fns).
25
25
 
26
26
  To install the package you need to have [npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm) (or [yarn](https://yarnpkg.com/getting-started/install)) and then run:
27
27
 
@@ -52,7 +52,7 @@ You could also import any individual module directly from an html page like this
52
52
  ```html
53
53
  <script type="module">
54
54
  import {
55
- namedtuple, Deque, Heap, SortedSet, SortedMap
55
+ namedtuple, FrozenSet, SortedSet, SortedMap
56
56
  } from 'https://unpkg.com/atomic-fns/core/collections';
57
57
  // your code goes here...
58
58
  </script>
@@ -66,7 +66,7 @@ This library features a data model similar to [Python](https://docs.python.org/3
66
66
  For example in Python collections `size()` is a method while in JS its just a property. So this library uses `size` property instead of methods. Similarly, the `len` function implementation checks for both `length` and `size` since many JS objects have a `length` property.
67
67
 
68
68
  ## Special method names
69
- This library adds support for operators via object methods like:
69
+ This library adds support for operators using object methods such as:
70
70
  - `obj.eq(other)` adds custom `obj == other`.
71
71
  - `obj.lt(other)` adds custom `obj < other`.
72
72
  - `obj.lte(other)` adds custom `obj <= other`.
@@ -76,11 +76,25 @@ This library adds support for operators via object methods like:
76
76
 
77
77
  When you implement those, you can also apply operators to values like `eq(x, y), lte(x, y), compare(x, y)`, etc. to get the result of `x.<operator>(y)`.
78
78
 
79
- Some new base types introduced: `Collection, Sequence, Mapping, FrozenSet, IterableIterator`.
79
+ ## New Types
80
+
81
+ Introduces some common base interfaces and typing patterns you may have seen like `Optional`, `Result`, `Comparable`, `Iterator`, and others.
82
+
83
+ ### Sorted Containers
84
+ - [SortedSet](https://atomic-fns.dev/classes/Collections.SortedSet.html)
85
+ - [SortedMap](https://atomic-fns.dev/classes/Collections.SortedMap.html)
86
+ - [SortedTree](https://atomic-fns.dev/classes/Collections.SortedTree.html)
87
+
88
+ ### Other Containers
89
+ - [Deque](https://atomic-fns.dev/classes/Collections.Deque.html)
90
+ - [FrozenSet](https://atomic-fns.dev/classes/Collections.FrozenSet.html)
91
+ - [LRUCache](https://atomic-fns.dev/classes/Collections.LRUCache.html)
92
+
80
93
 
81
94
  ## Contributing
82
95
  If you want to contribute to the project and make it better, your help is very welcome. Contributing is also a great way to learn more about social coding on Github, new technologies and and their ecosystems and how to make constructive, helpful bug reports, feature requests and the noblest of all contributions: a good, clean pull request. You will be listed as a **Champion** on the official site as well.
83
96
 
97
+
84
98
  ## License
85
99
 
86
100
  [Apache License 2.0](http://www.apache.org/licenses/LICENSE-2.0)
@@ -1,7 +1,9 @@
1
1
  import { Iteratee } from '../globals/index.js';
2
2
  import { Mapping } from './abc.js';
3
3
  /**
4
- * Base append-only Cache collection.
4
+ * Base append-only Cache collection that supports adding and accessing keys in O(1).
5
+ * The collection has a fixed given size (default 1024) and when full, it evicts keys using LRU approach. This operation is also O(1).
6
+ * @template K, V
5
7
  */
6
8
  export declare class Cache<K, V = any> extends Mapping<K, V> {
7
9
  capacity: number;
@@ -13,6 +15,12 @@ export declare class Cache<K, V = any> extends Mapping<K, V> {
13
15
  protected backward: Uint8Array | Uint16Array | Uint32Array;
14
16
  protected K: K[];
15
17
  protected V: V[];
18
+ /**
19
+ * Create a new cache object of fixed size.
20
+ * @param {number} [capacity=1024] The maximum number of keys to keep in cache.
21
+ * @param {Function} [Keys=Array] The constructor to use for the Keys array. When using numeric values, a TypedArray constructor can be used.
22
+ * @param {Function} [Values=Array] The constructor to use for the Values array. When using numeric values, a TypedArray constructor can be used.
23
+ */
16
24
  constructor(capacity?: number, Keys?: ArrayConstructor, Values?: ArrayConstructor);
17
25
  /**
18
26
  * This is just an alias of {@link Cache.set}.
@@ -30,6 +38,9 @@ export declare class Cache<K, V = any> extends Mapping<K, V> {
30
38
  * Method used to clear the structure.
31
39
  */
32
40
  clear(): void;
41
+ /**
42
+ * Returns the number of keys in the cache.
43
+ */
33
44
  get size(): number;
34
45
  /**
35
46
  * Method used to splay a value on top.
@@ -101,10 +112,20 @@ export declare class Cache<K, V = any> extends Mapping<K, V> {
101
112
  */
102
113
  inspect(): Map<any, any>;
103
114
  }
115
+ /**
116
+ * Implements a Least Recently Used fixed-capacity cache which supports updating, removing, and accessing keys in O(1).
117
+ */
104
118
  export declare class LRUCache<K, V> extends Cache<K, V> {
105
119
  deletedSize: number;
106
120
  deleted: Uint8Array | Uint16Array | Uint32Array;
121
+ /**
122
+ * Create a new LRU cache object of fixed size.
123
+ * @param {number} [capacity=1024] The maximum number of keys to keep in cache.
124
+ * @param {Function} [Keys=Array] The constructor to use for the Keys array. When using numeric values, a TypedArray constructor can be used.
125
+ * @param {Function} [Values=Array] The constructor to use for the Values array. When using numeric values, a TypedArray constructor can be used.
126
+ */
107
127
  constructor(capacity?: number, Keys?: ArrayConstructor, Values?: ArrayConstructor);
128
+ /** Remove all elements in the cache. */
108
129
  clear(): void;
109
130
  /**
110
131
  * Method used to set the value for the given key in the cache.
@@ -3,7 +3,9 @@ import { IterableIterator } from '../itertools/index.js';
3
3
  import { Mapping } from './abc.js';
4
4
  import { getPointerArray } from './typedArrays.js';
5
5
  /**
6
- * Base append-only Cache collection.
6
+ * Base append-only Cache collection that supports adding and accessing keys in O(1).
7
+ * The collection has a fixed given size (default 1024) and when full, it evicts keys using LRU approach. This operation is also O(1).
8
+ * @template K, V
7
9
  */
8
10
  export class Cache extends Mapping {
9
11
  capacity;
@@ -15,6 +17,12 @@ export class Cache extends Mapping {
15
17
  backward;
16
18
  K;
17
19
  V;
20
+ /**
21
+ * Create a new cache object of fixed size.
22
+ * @param {number} [capacity=1024] The maximum number of keys to keep in cache.
23
+ * @param {Function} [Keys=Array] The constructor to use for the Keys array. When using numeric values, a TypedArray constructor can be used.
24
+ * @param {Function} [Values=Array] The constructor to use for the Values array. When using numeric values, a TypedArray constructor can be used.
25
+ */
18
26
  constructor(capacity = 1024, Keys = Array, Values = Array) {
19
27
  super();
20
28
  this.capacity = capacity;
@@ -53,6 +61,9 @@ export class Cache extends Mapping {
53
61
  this.tail = 0;
54
62
  this.items = new Map();
55
63
  }
64
+ /**
65
+ * Returns the number of keys in the cache.
66
+ */
56
67
  get size() {
57
68
  return this.count;
58
69
  }
@@ -264,14 +275,24 @@ export class Cache extends Mapping {
264
275
  return this.inspect();
265
276
  }
266
277
  }
278
+ /**
279
+ * Implements a Least Recently Used fixed-capacity cache which supports updating, removing, and accessing keys in O(1).
280
+ */
267
281
  export class LRUCache extends Cache {
268
282
  deletedSize = 0;
269
283
  deleted;
284
+ /**
285
+ * Create a new LRU cache object of fixed size.
286
+ * @param {number} [capacity=1024] The maximum number of keys to keep in cache.
287
+ * @param {Function} [Keys=Array] The constructor to use for the Keys array. When using numeric values, a TypedArray constructor can be used.
288
+ * @param {Function} [Values=Array] The constructor to use for the Values array. When using numeric values, a TypedArray constructor can be used.
289
+ */
270
290
  constructor(capacity = 1024, Keys = Array, Values = Array) {
271
291
  super(capacity, Keys, Values);
272
292
  const PointerArray = getPointerArray(capacity);
273
293
  this.deleted = new PointerArray(capacity);
274
294
  }
295
+ /** Remove all elements in the cache. */
275
296
  clear() {
276
297
  super.clear();
277
298
  this.deletedSize = 0;
@@ -4,7 +4,9 @@ import { Mapping } from './abc.js'
4
4
  import { getPointerArray } from './typedArrays.js'
5
5
 
6
6
  /**
7
- * Base append-only Cache collection.
7
+ * Base append-only Cache collection that supports adding and accessing keys in O(1).
8
+ * The collection has a fixed given size (default 1024) and when full, it evicts keys using LRU approach. This operation is also O(1).
9
+ * @template K, V
8
10
  */
9
11
  export class Cache<K, V = any> extends Mapping<K, V> {
10
12
  capacity: number
@@ -17,6 +19,12 @@ export class Cache<K, V = any> extends Mapping<K, V> {
17
19
  protected K: K[]
18
20
  protected V: V[]
19
21
 
22
+ /**
23
+ * Create a new cache object of fixed size.
24
+ * @param {number} [capacity=1024] The maximum number of keys to keep in cache.
25
+ * @param {Function} [Keys=Array] The constructor to use for the Keys array. When using numeric values, a TypedArray constructor can be used.
26
+ * @param {Function} [Values=Array] The constructor to use for the Values array. When using numeric values, a TypedArray constructor can be used.
27
+ */
20
28
  constructor(capacity = 1024, Keys = Array, Values = Array) {
21
29
  super()
22
30
  this.capacity = capacity
@@ -61,6 +69,9 @@ export class Cache<K, V = any> extends Mapping<K, V> {
61
69
  this.items = new Map()
62
70
  }
63
71
 
72
+ /**
73
+ * Returns the number of keys in the cache.
74
+ */
64
75
  get size() {
65
76
  return this.count
66
77
  }
@@ -315,16 +326,26 @@ export class Cache<K, V = any> extends Mapping<K, V> {
315
326
  }
316
327
  }
317
328
 
329
+ /**
330
+ * Implements a Least Recently Used fixed-capacity cache which supports updating, removing, and accessing keys in O(1).
331
+ */
318
332
  export class LRUCache<K, V> extends Cache<K, V> {
319
333
  deletedSize = 0
320
334
  deleted: Uint8Array | Uint16Array | Uint32Array
321
335
 
336
+ /**
337
+ * Create a new LRU cache object of fixed size.
338
+ * @param {number} [capacity=1024] The maximum number of keys to keep in cache.
339
+ * @param {Function} [Keys=Array] The constructor to use for the Keys array. When using numeric values, a TypedArray constructor can be used.
340
+ * @param {Function} [Values=Array] The constructor to use for the Values array. When using numeric values, a TypedArray constructor can be used.
341
+ */
322
342
  constructor(capacity = 1024, Keys = Array, Values = Array) {
323
343
  super(capacity, Keys, Values)
324
344
  const PointerArray = getPointerArray(capacity)
325
345
  this.deleted = new PointerArray(capacity)
326
346
  }
327
347
 
348
+ /** Remove all elements in the cache. */
328
349
  clear() {
329
350
  super.clear()
330
351
  this.deletedSize = 0
@@ -1,6 +1,6 @@
1
1
  import { Mapping } from './abc.js';
2
2
  /**
3
- * A `SortedMap` is a map that holds key value pairs in sorted orders of keys. Any primitive value (and objects that implement a `compare` or `lt` methods) can be used as keys or values.
3
+ * A `SortedMap` is a map that holds key value pairs ordered by keys. Any primitive value (and objects that implement {@link Comparable} or {@link Ordered} interfaces) can be used as keys or values.
4
4
  * @see {@link Operators.compare}
5
5
  * @see {@link Operators.lt}
6
6
  * @template K, V
@@ -1,7 +1,7 @@
1
1
  import { Mapping } from './abc.js';
2
2
  import { SplayTree } from './SplayTree.js';
3
3
  /**
4
- * A `SortedMap` is a map that holds key value pairs in sorted orders of keys. Any primitive value (and objects that implement a `compare` or `lt` methods) can be used as keys or values.
4
+ * A `SortedMap` is a map that holds key value pairs ordered by keys. Any primitive value (and objects that implement {@link Comparable} or {@link Ordered} interfaces) can be used as keys or values.
5
5
  * @see {@link Operators.compare}
6
6
  * @see {@link Operators.lt}
7
7
  * @template K, V
@@ -2,7 +2,7 @@ import { Mapping } from './abc.js'
2
2
  import { SplayTree } from './SplayTree.js'
3
3
 
4
4
  /**
5
- * A `SortedMap` is a map that holds key value pairs in sorted orders of keys. Any primitive value (and objects that implement a `compare` or `lt` methods) can be used as keys or values.
5
+ * A `SortedMap` is a map that holds key value pairs ordered by keys. Any primitive value (and objects that implement {@link Comparable} or {@link Ordered} interfaces) can be used as keys or values.
6
6
  * @see {@link Operators.compare}
7
7
  * @see {@link Operators.lt}
8
8
  * @template K, V
@@ -1,4 +1,10 @@
1
1
  import { Collection } from './abc.js';
2
+ /**
3
+ * A `SortedSet` is a set that holds values in order. Any primitive value (and objects that implement {@link Comparable} or {@link Ordered} interfaces) can be used as values.
4
+ * @see {@link Compare}
5
+ * @see {@link Ordered}
6
+ * @template K, V
7
+ */
2
8
  export declare class SortedSet<T> extends Collection {
3
9
  private readonly store;
4
10
  /**
@@ -1,5 +1,11 @@
1
1
  import { Collection } from './abc.js';
2
2
  import { SplayTree } from './SplayTree.js';
3
+ /**
4
+ * A `SortedSet` is a set that holds values in order. Any primitive value (and objects that implement {@link Comparable} or {@link Ordered} interfaces) can be used as values.
5
+ * @see {@link Compare}
6
+ * @see {@link Ordered}
7
+ * @template K, V
8
+ */
3
9
  export class SortedSet extends Collection {
4
10
  store;
5
11
  /**
@@ -1,6 +1,12 @@
1
1
  import { Collection } from './abc.js'
2
2
  import { SplayTree } from './SplayTree.js'
3
3
 
4
+ /**
5
+ * A `SortedSet` is a set that holds values in order. Any primitive value (and objects that implement {@link Comparable} or {@link Ordered} interfaces) can be used as values.
6
+ * @see {@link Compare}
7
+ * @see {@link Ordered}
8
+ * @template K, V
9
+ */
4
10
  export class SortedSet<T> extends Collection {
5
11
  private readonly store: SplayTree<T>
6
12
  /**
@@ -1,9 +1,9 @@
1
1
  import { Comparer } from '../operators/index.js';
2
2
  import { Mapping } from './abc.js';
3
3
  /**
4
- * A `SortedTree` is a map that holds key value pairs in sorted orders of keys. Any primitive value (and objects that implement a `compare` or `lt` methods) can be used as keys or values.
5
- * @see {@link Operators.compare}
6
- * @see {@link Operators.lt}
4
+ * A `SortedTree` is a map that holds key value pairs ordered by keys. Any primitive value (and objects that implement {@link Comparable} or {@link Ordered} interfaces) can be used as keys or values.
5
+ * @see {@link Compare}
6
+ * @see {@link Ordered}
7
7
  * @template K, V
8
8
  */
9
9
  export declare class SortedTree<K, V> extends Mapping<K, V> {
@@ -1,9 +1,9 @@
1
1
  import { Mapping } from './abc.js';
2
2
  import { BTree } from './BTree.js';
3
3
  /**
4
- * A `SortedTree` is a map that holds key value pairs in sorted orders of keys. Any primitive value (and objects that implement a `compare` or `lt` methods) can be used as keys or values.
5
- * @see {@link Operators.compare}
6
- * @see {@link Operators.lt}
4
+ * A `SortedTree` is a map that holds key value pairs ordered by keys. Any primitive value (and objects that implement {@link Comparable} or {@link Ordered} interfaces) can be used as keys or values.
5
+ * @see {@link Compare}
6
+ * @see {@link Ordered}
7
7
  * @template K, V
8
8
  */
9
9
  export class SortedTree extends Mapping {
@@ -3,9 +3,9 @@ import { Mapping } from './abc.js'
3
3
  import { BTree } from './BTree.js'
4
4
 
5
5
  /**
6
- * A `SortedTree` is a map that holds key value pairs in sorted orders of keys. Any primitive value (and objects that implement a `compare` or `lt` methods) can be used as keys or values.
7
- * @see {@link Operators.compare}
8
- * @see {@link Operators.lt}
6
+ * A `SortedTree` is a map that holds key value pairs ordered by keys. Any primitive value (and objects that implement {@link Comparable} or {@link Ordered} interfaces) can be used as keys or values.
7
+ * @see {@link Compare}
8
+ * @see {@link Ordered}
9
9
  * @template K, V
10
10
  */
11
11
  export class SortedTree<K, V> extends Mapping<K, V> {
@@ -32,7 +32,7 @@ export interface Ordered<T> {
32
32
  * Implements an iterable that allows backward iteration.
33
33
  * @interface Reversible
34
34
  */
35
- export interface Reversible<T = unknown> {
35
+ export interface Reversible<T = any> {
36
36
  reversed: () => Iterable<T>;
37
37
  }
38
38
  /**
@@ -36,7 +36,7 @@ export interface Ordered<T> {
36
36
  * Implements an iterable that allows backward iteration.
37
37
  * @interface Reversible
38
38
  */
39
- export interface Reversible<T = unknown> {
39
+ export interface Reversible<T = any> {
40
40
  reversed: () => Iterable<T>
41
41
  }
42
42
 
@@ -2,107 +2,114 @@ import { Iteratee } from '../globals/index.js';
2
2
  import { Sequence } from './abc.js';
3
3
  /**
4
4
  * Fixed capacity double-ended queue implemented as ring deque.
5
- *
6
- * @constructor
5
+ * @template T
7
6
  */
8
- export declare class Deque<T> extends Sequence<T> {
7
+ export declare class Deque<T = any> extends Sequence<T> {
9
8
  items: T[];
10
9
  start: number;
11
10
  count: number;
12
11
  capacity: number;
13
- ArrayClass: any;
14
- constructor(ArrayClass?: T[], capacity?: number);
12
+ ArrayConstructor: any;
13
+ /**
14
+ * Creates a new `Deque` instance of a fixed size.
15
+ * @param {Array} [arrType = []] The initial elements or array type to use (accepts any kind of typed array).
16
+ * @param {number} [capacity=1024] The fixed size of the deque. Defaults to `1024`.
17
+ */
18
+ constructor(arrType?: T[], capacity?: number);
19
+ /** Returns the total number of elements in the deque. */
15
20
  get size(): number;
16
21
  /**
17
22
  * Method used to clear the structure.
18
- *
19
- * @return {undefined}
20
23
  */
21
24
  clear(): void;
22
25
  /**
23
26
  * Alias of {@link Deque.append}
24
- *
25
- * @param {any} item - Item to append.
26
- * @return {number} - Returns the new size of the deque.
27
+ * @param {T} item Item to append.
28
+ * @returns {number} Returns the new size of the deque.
27
29
  */
28
30
  add(item: any): number;
29
31
  /**
30
- * Method used to append a value to the deque.
31
- *
32
- * @param {any} item - Item to append.
33
- * @return {number} - Returns the new size of the deque.
32
+ * Appends a new element to the end of the deque.
33
+ * @param {T} item Item to append.
34
+ * @returns {number} Returns the new size of the deque.
34
35
  */
35
36
  append(item: any): number;
36
37
  /**
37
- * Method used to prepend a value to the deque.
38
- *
39
- * @param {any} item - Item to prepend.
40
- * @return {number} - Returns the new size of the deque.
38
+ * Appends a new element to the beginning of the deque.
39
+ * @param {T} item Item to prepend.
40
+ * @returns {number} Returns the new size of the deque.
41
41
  */
42
42
  appendleft(item: any): number;
43
43
  /**
44
- * Method used to pop the deque.
45
- *
46
- * @return {any} - Returns the popped item.
44
+ * Removes and returns the element at the end of the deque.
45
+ * @returns {?T} Returns the popped item.
47
46
  */
48
47
  pop(): T | undefined;
49
48
  /**
50
49
  * Alias of {@link Deque.pop}
50
+ * @returns {?T} Returns the popped item.
51
51
  */
52
52
  remove(): T | undefined;
53
53
  /**
54
- * Method used to shift the deque.
55
- *
56
- * @return {any} - Returns the shifted item.
54
+ * Removes and returns the element at the beginning of the deque.
55
+ * @returns {?T} Returns the removed deque element.
57
56
  */
58
57
  popleft(): T | undefined;
59
58
  /**
60
- * Method used to peek the first value of the deque.
61
- *
62
- * @return {any}
59
+ * Returns the element at the beginning of the deque.
60
+ * @returns {?T} The element if exists
63
61
  */
64
62
  first(): T | undefined;
65
63
  /**
66
- * Method used to get the desired value of the deque.
67
- *
68
- * @param {number} index
69
- * @return {any}
64
+ * Returns the element at a specified index position in the deque.
65
+ * @param {number} index The given index
66
+ * @returns {?T} The element if exists
70
67
  */
71
68
  get(index: any): T | undefined;
72
69
  /**
73
- * Update the value at a given `index`.
74
- * @param index The given index
75
- * @param value The new value to set at `index`.
70
+ * Update the element at a given `index`.
71
+ * @param {number} index The given index
76
72
  */
77
73
  set(index: number, value: T): void;
74
+ /**
75
+ * Check if a given element is in the deque.
76
+ * @param {T} x The value to find
77
+ * @returns {boolean} `true` if the value is found
78
+ */
78
79
  contains(x: any): boolean;
80
+ /**
81
+ * Returns the first element that matches the `iteratee` function.
82
+ * @param {Iteratee<T>} iteratee A function that will be invoked per element
83
+ * @returns {?T} The element if exists
84
+ */
79
85
  find(iteratee: Iteratee<T>): T | undefined;
80
86
  /**
81
- * Method used to iterate over the deque.
82
- *
83
- * @param {function} iteratee - Function to call for each item.
84
- * @param {object} scope - Optional scope.
85
- * @return {undefined}
87
+ * Calls `iteratee` function for every element in the deque.
88
+ * @param {Iteratee<T>} iteratee A function that will be invoked per element
86
89
  */
87
90
  forEach(iteratee: any): void;
91
+ /**
92
+ * Returns a new array with all the elements in reverse order.
93
+ * @returns {Array<T>} The elements reversed
94
+ */
88
95
  reversed(): any;
89
96
  /**
90
- * Method used to convert the deque to a JavaScript array.
91
- *
92
- * @return {array}
97
+ * Returns a new array with all the elements in the order they were added to the deque.
98
+ * @returns {Array<T>} The elements array
93
99
  */
94
100
  toArray(): any;
95
101
  /**
96
- * Method used to create an iterator over the deque's values.
97
- *
98
- * @return {Iterator}
102
+ * Returns an iterator over the deque's values.
103
+ * @returns {Iterator}
99
104
  */
100
105
  values(): Iterable<T>;
106
+ /**
107
+ * Alias of {@link Deque.values}. Returns iterator of values.
108
+ */
101
109
  keys(): Iterable<T>;
102
110
  /**
103
- * Method used to create an iterator over the deque's entries.
104
- *
105
- * @return {Iterator}
111
+ * Creates an iterator of `[index, value]` pairs for all elements in the deque.
112
+ * @returns {Iterator}
106
113
  */
107
114
  entries(): Iterator<[number, T], any, undefined> & Iterable<[number, T]>;
108
115
  [Symbol.iterator](): Iterable<T>;