atomic-fns 0.2.2 → 0.3.0

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 (70) hide show
  1. package/.firebaserc +5 -0
  2. package/README.md +9 -4
  3. package/firebase.json +10 -0
  4. package/package.json +9 -9
  5. package/src/collections/index.d.ts +672 -0
  6. package/src/collections/index.js +1091 -0
  7. package/src/collections/index.ts +1186 -0
  8. package/src/datetime/index.d.ts +6 -0
  9. package/src/datetime/index.js +6 -0
  10. package/src/datetime/index.ts +7 -0
  11. package/src/functools/index.d.ts +107 -0
  12. package/src/functools/index.js +219 -0
  13. package/src/functools/index.ts +255 -0
  14. package/src/globals/index.d.ts +286 -0
  15. package/src/globals/index.js +388 -0
  16. package/src/globals/index.ts +451 -0
  17. package/src/index.d.ts +8 -7
  18. package/src/index.js +8 -7
  19. package/src/index.ts +8 -7
  20. package/src/itertools/index.d.ts +225 -0
  21. package/src/itertools/index.js +449 -0
  22. package/src/itertools/index.ts +471 -0
  23. package/src/math/index.d.ts +97 -0
  24. package/src/math/index.js +92 -0
  25. package/src/math/index.ts +152 -0
  26. package/src/{operators.d.ts → operators/index.d.ts} +11 -9
  27. package/src/operators/index.js +171 -0
  28. package/src/operators/index.ts +175 -0
  29. package/src/random/index.d.ts +42 -0
  30. package/src/random/index.js +65 -0
  31. package/src/random/index.ts +66 -0
  32. package/tests/collections.spec.ts +42 -25
  33. package/tests/globals.spec.ts +56 -60
  34. package/tests/itertools.spec.ts +176 -4
  35. package/tests/math.spec.ts +25 -0
  36. package/tests/operators.spec.ts +1 -26
  37. package/tests/random.spec.ts +46 -0
  38. package/tsconfig.json +12 -4
  39. package/src/collections.d.ts +0 -228
  40. package/src/collections.js +0 -553
  41. package/src/collections.ts +0 -641
  42. package/src/datetime.d.ts +0 -5
  43. package/src/datetime.js +0 -5
  44. package/src/datetime.ts +0 -6
  45. package/src/functools.d.ts +0 -40
  46. package/src/functools.js +0 -78
  47. package/src/functools.ts +0 -93
  48. package/src/globals.d.ts +0 -179
  49. package/src/globals.js +0 -309
  50. package/src/globals.ts +0 -377
  51. package/src/itertools.d.ts +0 -20
  52. package/src/itertools.js +0 -98
  53. package/src/itertools.ts +0 -116
  54. package/src/math.d.ts +0 -16
  55. package/src/math.js +0 -70
  56. package/src/math.ts +0 -77
  57. package/src/objects.d.ts +0 -0
  58. package/src/objects.js +0 -1
  59. package/src/objects.ts +0 -0
  60. package/src/operators.js +0 -109
  61. package/src/operators.ts +0 -130
  62. package/src/random.d.ts +0 -22
  63. package/src/random.js +0 -48
  64. package/src/random.ts +0 -53
  65. package/src/strings.d.ts +0 -0
  66. package/src/strings.js +0 -1
  67. package/src/strings.ts +0 -0
  68. package/src/util.d.ts +0 -0
  69. package/src/util.js +0 -1
  70. package/src/util.ts +0 -0
@@ -1,228 +0,0 @@
1
- /**
2
- * Collections
3
- * @module
4
- */
5
- import { Function, Iteratee } from './globals.js';
6
- /**
7
- * A container type that provides contains().
8
- *
9
- *
10
- * @interface Container
11
- */
12
- export interface Container {
13
- contains: (x: any) => boolean;
14
- }
15
- /**
16
- * These are the "rich comparison" methods, inspired by Python operators.
17
- *
18
- *
19
- * @interface Comparable
20
- */
21
- export interface Comparable {
22
- /** x < y: calls this.lt(other) reflection. */
23
- lt?: (other: any) => boolean;
24
- /** x ≤ y: calls this.le(other) reflection. */
25
- le?: (other: any) => boolean;
26
- /** x == y: calls this.eq(other) reflection. */
27
- eq: (other: any) => boolean;
28
- /** x != y: calls this.ne(other) reflection. */
29
- ne: (other: any) => boolean;
30
- /** x > y: calls this.gt(other) reflection. */
31
- gt?: (other: any) => boolean;
32
- /** x ≥ y: calls this.ge(other) reflection. */
33
- ge?: (other: any) => boolean;
34
- }
35
- /**
36
- * A Collection is an iterable container type.
37
- * This is an abstract base class for user-defined collection types.
38
- *
39
- *
40
- * @abstract
41
- * @class Collection
42
- * @implements {Container}
43
- */
44
- export declare abstract class Collection implements Container {
45
- /**
46
- * Returns an iterator for the container items
47
- * @return {Iterator}
48
- */
49
- [Symbol.iterator](): this;
50
- /**
51
- * Implements the iterator protocol and returns the next item in the iterable.
52
- */
53
- next(): void;
54
- /**
55
- * Adds a new item to the container.
56
- * @param item
57
- */
58
- add(item: any): void;
59
- /**
60
- * Checks if item is present in the container.
61
- * @param item
62
- */
63
- contains(item: any): boolean;
64
- /**
65
- * Returns the total number of elements in the container.
66
- */
67
- size(): number;
68
- /**
69
- * Remove the first item from the container where `item == x`
70
- * @raises ValueError when x is not found
71
- */
72
- remove(x: any): void;
73
- /**
74
- * Retrieve and remove the item at index `i`.
75
- * @returns the item or undefined if not found.
76
- */
77
- pop(i: any): void;
78
- /**
79
- * Remove all items from the container
80
- */
81
- clear(): void;
82
- }
83
- /**
84
- * Implements an iterable that allows backward iteration.
85
- * @interface Reversible
86
- */
87
- export interface Reversible<T = unknown> {
88
- reversed: () => Iterator<T>;
89
- }
90
- /**
91
- * A sequence is an iterable type with efficient index-based access.
92
- *
93
- *
94
- * @abstract
95
- * @class Sequence
96
- * @extends {Collection}
97
- * @template T
98
- */
99
- export declare abstract class Sequence<T> extends Collection implements Reversible<T> {
100
- /**
101
- * Return the item at the given key or index
102
- * @param {*} key
103
- * @memberof Sequence
104
- */
105
- get(key: any): T | undefined;
106
- /**
107
- * Set a new value at the given key or index
108
- *
109
- * @param {*} key
110
- * @param {T} val
111
- * @memberof Sequence
112
- */
113
- set(key: any, val: T): void;
114
- /**
115
- * Deletes the given key or index, and its value.
116
- * Raises ValueError if not key is found.
117
- *
118
- * @param {*} key
119
- * @memberof Sequence
120
- */
121
- delete(key: any): void;
122
- /**
123
- * Adds a new item to the end of the sequence.
124
- *
125
- * @param {T} x
126
- * @memberof Sequence
127
- */
128
- append(x: T): void;
129
- /**
130
- * Append all the items to the sequence.
131
- *
132
- * @param {Iterable<T>} iter
133
- * @memberof Sequence
134
- */
135
- extend(iter: Iterable<T>): void;
136
- /**
137
- * Return the index of x in the sequence, or undefined if not found.
138
- *
139
- * @param {T} item
140
- * @return {(number | undefined)}
141
- * @memberof Sequence
142
- */
143
- indexOf(item: T): number | undefined;
144
- size(): number;
145
- reversed(): Iterator<T>;
146
- }
147
- /**
148
- * Returns a new immutable Set object with elements from `iterable`. Its contents cannot be altered after it's created.
149
- *
150
- *
151
- * @class FrozenSet
152
- * @extends {Set<T>}
153
- * @template T
154
- */
155
- export declare class FrozenSet<T = any> extends Set<T> {
156
- constructor(iterable: Iterable<T>);
157
- add(): this;
158
- delete(): boolean;
159
- clear(): this;
160
- freeze(): Readonly<this>;
161
- }
162
- export declare const compact: (...arr: any[]) => any[];
163
- /**
164
- * Creates a function that can be used to create named tuple-like objects.
165
- * @example
166
- * ```
167
- * let Point = namedtuple('x', 'y', 'z')
168
- * let userObj = User(0, 0, 0)
169
- * // -> {x: 0, y: 0, z: 0}
170
- * ```
171
- *
172
- *
173
- * @param {...string[]} fields
174
- * @return
175
- */
176
- export declare function namedtuple(...fields: string[]): (...args: any[]) => {};
177
- export declare function filter(arr: any, fn?: Iteratee | PropertyKey | Object): any[] | undefined;
178
- export declare function find(arr: any, fn: Iteratee | PropertyKey | Object): any;
179
- export declare function findRight(arr: any, fn: Iteratee | PropertyKey | Object): any;
180
- export declare const matches: (o: any) => (x: any) => boolean;
181
- export declare function forEach(arr: any[], fn: Iteratee): any;
182
- export declare function forEach(arr: Object, fn: Iteratee): any;
183
- export declare function flatten(arr: any, depth?: boolean | number): any;
184
- export declare function flattenArray(arr: any[], depth?: boolean | number, result?: any[]): any[];
185
- export declare function flattenObj(o: any, prefix?: string, result?: {}, keepNull?: boolean): {};
186
- export declare const map: (arr: any, fn: Function | string) => any[] | undefined;
187
- export declare function pick(obj: any, paths: Iteratee | string[]): {};
188
- export declare function omit(obj: any, paths: Iteratee | string[]): {};
189
- export declare function contains(arr: any, y: any): any;
190
- export declare function indexOf(obj: any, x: any, start?: number): any;
191
- export declare function lastIndexOf(obj: any, x: any, start?: any): any;
192
- /**
193
- * Creates a clone of the given `obj`. If `deep` is `true` it will clone it recursively.
194
- *
195
- *
196
- * @param {*} obj
197
- * @param {boolean} [deep=false]
198
- * @return The clone value
199
- */
200
- export declare function clone(obj: any, deep?: boolean): any;
201
- export declare function cloneArray(arr: any, deep?: boolean): any;
202
- export declare function cloneArrayBuffer(arrayBuffer: any): any;
203
- export declare function cloneTypedArray(typedArray: any, isDeep: any): any;
204
- export declare function uniq<T = any>(arr: T[], fn?: string | Iteratee): T[];
205
- export declare function sortedUniq(arr: any, fn?: string | Iteratee): any[];
206
- /**
207
- * Recursively merges own and inherited enumerable string keyed properties of source objects into the destination object. Source properties that resolve to `undefined` are skipped if a destination value exists. Array and plain object properties are merged recursively. Other objects and value types are overridden by assignment. Source objects are applied from left to right. Subsequent sources overwrite property assignments of previous sources.
208
- *
209
- * Note: this method mutates `obj`
210
- *
211
- *
212
- * @param {Object} obj
213
- * @param {...Object} sources
214
- * @return {Object} The destination object.
215
- */
216
- export declare function merge(obj: any, ...sources: any[]): Object;
217
- export declare function difference(...args: any[]): Generator<unknown, void, unknown>;
218
- export declare function intersection(...args: any[]): Generator<any, void, unknown>;
219
- export declare function union(...args: any[]): Generator<unknown, void, unknown>;
220
- /**
221
- * Creates an object composed of keys generated from the results of running each element of `arr` thru `func`. The order of grouped values is determined by the order they occur in `arr`. The corresponding value of each key is an array of elements responsible for generating the key.
222
- *
223
- *
224
- * @param {(any[] | Object)} arr The collection to iterate over.
225
- * @param {(Iteratee | PropertyKey)} [func=id] The iteratee to transform keys.
226
- * @return {Object} Returns the composed aggregate object.
227
- */
228
- export declare function groupBy(arr: any[] | Object, func?: Iteratee | PropertyKey): Object;