atomic-fns 0.2.0 → 0.2.3

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