atomic-fns 1.1.1 → 1.1.2
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.
- package/README.md +9 -7
- package/dist/collections/SortedMap.d.ts +2 -2
- package/dist/collections/SortedMap.js +2 -2
- package/dist/collections/index.d.ts +2 -1
- package/dist/collections/index.js +2 -1
- package/dist/decimal/index.d.ts +4 -2
- package/dist/decimal/index.js +4 -2
- package/dist/functools/index.d.ts +1 -1
- package/dist/functools/index.js +1 -1
- package/dist/globals/index.d.ts +1 -1
- package/dist/globals/index.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/itertools/index.d.ts +2 -2
- package/dist/itertools/index.js +2 -2
- package/dist/math/index.d.ts +1 -1
- package/dist/math/index.js +1 -1
- package/dist/operators/index.d.ts +3 -3
- package/dist/operators/index.js +3 -3
- package/dist/random/index.d.ts +1 -1
- package/dist/random/index.js +1 -1
- package/dist/types.d.ts +10 -10
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
[Read the Docs](https://atomic-fns.dev)
|
|
4
4
|
|
|
5
|
-
## Like Lodash, but in TypeScript and for
|
|
5
|
+
## Like Lodash, but in TypeScript and for ESNext.
|
|
6
6
|
|
|
7
7
|
Stop shipping code built for browsers from 2015. Really though, look at all the [issues](https://github.com/lodash/lodash/issues/2930).
|
|
8
8
|
|
|
@@ -10,10 +10,10 @@ You may prefer this because it's:
|
|
|
10
10
|
|
|
11
11
|
* **TypeScript & docs**: Includes type declaration files and js with JSDocs for best in class experience.
|
|
12
12
|
* **Zero deps**: Built from scratch with no runtime dependencies or polyfills.
|
|
13
|
-
* **
|
|
14
|
-
* **Modular**: Pick what you need. Supports tree-shaking, no side effects and works with all bundlers.
|
|
13
|
+
* **ESNext**: Uses modern idiomatic syntax, data structures, and control flow techniques.
|
|
14
|
+
* **Modular**: Pick what you need. Supports tree-shaking, no side effects, and works with all bundlers.
|
|
15
15
|
* **Lazy**: Leverage generators, iterators, and functional composition.
|
|
16
|
-
* **
|
|
16
|
+
* **Tests**: All modules have comprehensive test suites and public apis are 100% covered.
|
|
17
17
|
|
|
18
18
|
## Docs
|
|
19
19
|
|
|
@@ -52,7 +52,7 @@ See the full list of [modules](https://atomic-fns.dev/modules.html).
|
|
|
52
52
|
## Data model
|
|
53
53
|
This library features a data model similar to [Python](https://docs.python.org/3/reference/datamodel.html#special-method-names) but not always. Only the missing parts have been implemented, while respecting the JS standards.
|
|
54
54
|
|
|
55
|
-
For example in Python collections `size()` is a method while in JS
|
|
55
|
+
For example, in Python collections, `size()` is a method, while in JS it's just a property. So this library uses `size` property instead of method. Similarly, the `len` function implementation checks for both `length` and `size` since many JS objects have a `length` property.
|
|
56
56
|
|
|
57
57
|
## Special method names
|
|
58
58
|
This library adds support for operators using object methods such as:
|
|
@@ -63,11 +63,13 @@ This library adds support for operators using object methods such as:
|
|
|
63
63
|
- `obj.gte(other)` adds custom `obj >= other`.
|
|
64
64
|
- `obj.compare(other)` overloads sorting operations.
|
|
65
65
|
|
|
66
|
-
When
|
|
66
|
+
When working with objects, functions in this library use these custom operators for equality and sorting. You can also apply operators to values like `eq(x, y)`, `lte(x, y)`, `compare(x, y)`, etc.
|
|
67
67
|
|
|
68
68
|
## New Types
|
|
69
69
|
|
|
70
|
-
|
|
70
|
+
[`Decimal`](https://atomic-fns.dev/classes/decimal.Decimal.html) provides support for correct rounded floating point arithmetic, with arbitrary precision.
|
|
71
|
+
|
|
72
|
+
Some common base interfaces and typing patterns you may have seen like `Optional`, `Result`, `Comparable`, `Iterator`, and others.
|
|
71
73
|
|
|
72
74
|
### Sorted Containers
|
|
73
75
|
- [SortedSet](https://atomic-fns.dev/classes/Collections.SortedSet.html)
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Mapping } from './abc.js';
|
|
2
2
|
/**
|
|
3
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
|
-
* @see {@link
|
|
5
|
-
* @see {@link
|
|
4
|
+
* @see {@link operators.compare}
|
|
5
|
+
* @see {@link operators.lt}
|
|
6
6
|
* @template K, V
|
|
7
7
|
*/
|
|
8
8
|
export declare class SortedMap<K, V> extends Mapping<K, V> {
|
|
@@ -2,8 +2,8 @@ import { Mapping } from './abc.js';
|
|
|
2
2
|
import { SplayTree } from './SplayTree.js';
|
|
3
3
|
/**
|
|
4
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
|
-
* @see {@link
|
|
6
|
-
* @see {@link
|
|
5
|
+
* @see {@link operators.compare}
|
|
6
|
+
* @see {@link operators.lt}
|
|
7
7
|
* @template K, V
|
|
8
8
|
*/
|
|
9
9
|
export class SortedMap extends Mapping {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* This module includes classes and functions to work with Container types.
|
|
3
3
|
*
|
|
4
|
-
* @module
|
|
4
|
+
* @module collections
|
|
5
5
|
*/
|
|
6
6
|
import { compare } from '../operators/index.js';
|
|
7
7
|
import { Iteratee } from '../types';
|
|
@@ -15,6 +15,7 @@ export * from './SortedMap.js';
|
|
|
15
15
|
export * from './SortedSet.js';
|
|
16
16
|
export * from './SortedTree.js';
|
|
17
17
|
export * from './SplayTree.js';
|
|
18
|
+
export * from './Trie.js';
|
|
18
19
|
/**
|
|
19
20
|
* Creates a new array with all falsy and empty values removed.
|
|
20
21
|
* @param arr The array to compact
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* This module includes classes and functions to work with Container types.
|
|
3
3
|
*
|
|
4
|
-
* @module
|
|
4
|
+
* @module collections
|
|
5
5
|
*/
|
|
6
6
|
import { call, get, isArray, isArrayLike, isBool, isEmpty, isFunction, isIterable, isNull, isNumber, isObject, isString, keys, set } from '../globals/index.js';
|
|
7
7
|
import { enumerate } from '../itertools/index.js';
|
|
@@ -16,6 +16,7 @@ export * from './SortedMap.js';
|
|
|
16
16
|
export * from './SortedSet.js';
|
|
17
17
|
export * from './SortedTree.js';
|
|
18
18
|
export * from './SplayTree.js';
|
|
19
|
+
export * from './Trie.js';
|
|
19
20
|
export function compact(arr) {
|
|
20
21
|
if (!arr)
|
|
21
22
|
return;
|
package/dist/decimal/index.d.ts
CHANGED
|
@@ -8,7 +8,9 @@
|
|
|
8
8
|
*/
|
|
9
9
|
export declare function decimal(x: any): Decimal;
|
|
10
10
|
/**
|
|
11
|
-
* `Decimal` provides support for correct rounded floating point arithmetic, unlike the standard
|
|
11
|
+
* `Decimal` provides support for correct rounded floating point arithmetic, unlike the standard
|
|
12
|
+
* `Number` type. It also supports user-defined precision (default is 20 decimal places), which
|
|
13
|
+
* can be as large as needed.
|
|
12
14
|
*/
|
|
13
15
|
export declare class Decimal {
|
|
14
16
|
static PRECISION: number;
|
|
@@ -25,7 +27,7 @@ export declare class Decimal {
|
|
|
25
27
|
* @example
|
|
26
28
|
```js
|
|
27
29
|
let a = decimal('5')
|
|
28
|
-
a.
|
|
30
|
+
a.negated() // -5
|
|
29
31
|
```
|
|
30
32
|
* @returns {Decimal}
|
|
31
33
|
*/
|
package/dist/decimal/index.js
CHANGED
|
@@ -11,7 +11,9 @@ export function decimal(x) {
|
|
|
11
11
|
return new Decimal(x);
|
|
12
12
|
}
|
|
13
13
|
/**
|
|
14
|
-
* `Decimal` provides support for correct rounded floating point arithmetic, unlike the standard
|
|
14
|
+
* `Decimal` provides support for correct rounded floating point arithmetic, unlike the standard
|
|
15
|
+
* `Number` type. It also supports user-defined precision (default is 20 decimal places), which
|
|
16
|
+
* can be as large as needed.
|
|
15
17
|
*/
|
|
16
18
|
export class Decimal {
|
|
17
19
|
static PRECISION = 20;
|
|
@@ -86,7 +88,7 @@ export class Decimal {
|
|
|
86
88
|
* @example
|
|
87
89
|
```js
|
|
88
90
|
let a = decimal('5')
|
|
89
|
-
a.
|
|
91
|
+
a.negated() // -5
|
|
90
92
|
```
|
|
91
93
|
* @returns {Decimal}
|
|
92
94
|
*/
|
package/dist/functools/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* This module includes functions that promote a more functional programming style.
|
|
3
3
|
*
|
|
4
|
-
* @module
|
|
4
|
+
* @module functools
|
|
5
5
|
*/
|
|
6
6
|
/**
|
|
7
7
|
* Creates a function that invokes `fn` with the this binding of `thisArg` and `partials` as partially applied arguments.
|
package/dist/globals/index.d.ts
CHANGED
package/dist/globals/index.js
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* This module includes functions that deal with or produce iterators.
|
|
3
3
|
*
|
|
4
|
-
* @module
|
|
4
|
+
* @module itertools
|
|
5
5
|
*/
|
|
6
6
|
import { add, Comparer } from '../operators/index.js';
|
|
7
7
|
import { Function, Iteratee, Predicate } from '../types';
|
|
@@ -72,7 +72,7 @@ contains('abcd', 'bc')
|
|
|
72
72
|
// true
|
|
73
73
|
```
|
|
74
74
|
*
|
|
75
|
-
* @see {@link
|
|
75
|
+
* @see {@link collections.find}
|
|
76
76
|
*/
|
|
77
77
|
export declare function contains(collection: Iterable<any>, value: any): any;
|
|
78
78
|
/**
|
package/dist/itertools/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* This module includes functions that deal with or produce iterators.
|
|
3
3
|
*
|
|
4
|
-
* @module
|
|
4
|
+
* @module itertools
|
|
5
5
|
*/
|
|
6
6
|
import { call, isEmpty, isObject, notNull, ValueError } from '../globals/index.js';
|
|
7
7
|
import { add, bool, compare, eq, id } from '../operators/index.js';
|
|
@@ -99,7 +99,7 @@ contains('abcd', 'bc')
|
|
|
99
99
|
// true
|
|
100
100
|
```
|
|
101
101
|
*
|
|
102
|
-
* @see {@link
|
|
102
|
+
* @see {@link collections.find}
|
|
103
103
|
*/
|
|
104
104
|
export function contains(collection, value) {
|
|
105
105
|
if (!collection)
|
package/dist/math/index.d.ts
CHANGED
package/dist/math/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Generic operations for both values and objects.
|
|
3
3
|
*
|
|
4
|
-
* @module
|
|
4
|
+
* @module operators
|
|
5
5
|
*/
|
|
6
6
|
/** This is the identity function. It always returns the same value that was passed in */
|
|
7
7
|
export declare const id: (x: any) => any;
|
|
@@ -35,8 +35,8 @@ export declare type Comparer<T = any> = (x: T, y: T) => number;
|
|
|
35
35
|
* @param {*} y Other value to compare
|
|
36
36
|
* @returns {number} The comparison result
|
|
37
37
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#parameters Array.sort()}
|
|
38
|
-
* @see {@link
|
|
39
|
-
* @see {@link
|
|
38
|
+
* @see {@link operators.eq}
|
|
39
|
+
* @see {@link operators.lt}
|
|
40
40
|
*/
|
|
41
41
|
export declare function compare(x: any, y: any): number;
|
|
42
42
|
/**
|
package/dist/operators/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Generic operations for both values and objects.
|
|
3
3
|
*
|
|
4
|
-
* @module
|
|
4
|
+
* @module operators
|
|
5
5
|
*/
|
|
6
6
|
import { call, isObject } from '../globals/index.js';
|
|
7
7
|
/** This is the identity function. It always returns the same value that was passed in */
|
|
@@ -36,8 +36,8 @@ export const isinstance = (x, y) => x instanceof y;
|
|
|
36
36
|
* @param {*} y Other value to compare
|
|
37
37
|
* @returns {number} The comparison result
|
|
38
38
|
* @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort#parameters Array.sort()}
|
|
39
|
-
* @see {@link
|
|
40
|
-
* @see {@link
|
|
39
|
+
* @see {@link operators.eq}
|
|
40
|
+
* @see {@link operators.lt}
|
|
41
41
|
*/
|
|
42
42
|
export function compare(x, y) {
|
|
43
43
|
if (x === y || eq(x, y))
|
package/dist/random/index.d.ts
CHANGED
package/dist/random/index.js
CHANGED
package/dist/types.d.ts
CHANGED
|
@@ -4,16 +4,16 @@
|
|
|
4
4
|
export declare type Function<TReturn = any> = (...args: any) => TReturn;
|
|
5
5
|
/**
|
|
6
6
|
* An iteratee function used for collection methods.
|
|
7
|
-
* @see {@link
|
|
8
|
-
* @see {@link
|
|
9
|
-
* @see {@link
|
|
10
|
-
* @see {@link
|
|
11
|
-
* @see {@link
|
|
12
|
-
* @see {@link
|
|
13
|
-
* @see {@link
|
|
14
|
-
* @see {@link
|
|
15
|
-
* @see {@link
|
|
16
|
-
* @see {@link
|
|
7
|
+
* @see {@link collections.filter}
|
|
8
|
+
* @see {@link collections.find}
|
|
9
|
+
* @see {@link collections.forEach}
|
|
10
|
+
* @see {@link collections.index}
|
|
11
|
+
* @see {@link collections.map}
|
|
12
|
+
* @see {@link collections.pick}
|
|
13
|
+
* @see {@link collections.omit}
|
|
14
|
+
* @see {@link collections.uniq}
|
|
15
|
+
* @see {@link collections.sortedUniq}
|
|
16
|
+
* @see {@link collections.groupBy}
|
|
17
17
|
*/
|
|
18
18
|
export declare type Iteratee<T = any, K = any, TResult = any> = (value: T, key?: K, arr?: any) => TResult;
|
|
19
19
|
export declare type Predicate<T = any, TReturn = any> = (value: T) => TReturn;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "atomic-fns",
|
|
3
3
|
"description": "Like Lodash, but for ESNext and with types. Stop shipping code built for browsers from 2015.",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.2",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist/*"
|
|
7
7
|
],
|
|
@@ -67,5 +67,5 @@
|
|
|
67
67
|
"bugs": {
|
|
68
68
|
"url": "https://github.com/adrian2x/atomic-fns/issues"
|
|
69
69
|
},
|
|
70
|
-
"homepage": "https://
|
|
70
|
+
"homepage": "https://atomic-fns.dev"
|
|
71
71
|
}
|