atomic-fns 0.1.1 → 0.2.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.
Files changed (54) hide show
  1. package/.esdoc.json +27 -0
  2. package/.eslintrc.json +1 -0
  3. package/README.md +16 -17
  4. package/package.json +24 -13
  5. package/{build → src}/collections.d.ts +34 -10
  6. package/src/collections.js +553 -0
  7. package/src/collections.ts +48 -21
  8. package/{build → src}/datetime.d.ts +4 -0
  9. package/src/datetime.js +5 -0
  10. package/src/datetime.ts +5 -0
  11. package/{build → src}/functools.d.ts +7 -3
  12. package/{build → src}/functools.js +48 -49
  13. package/src/functools.ts +7 -3
  14. package/src/globals.d.ts +178 -4
  15. package/src/globals.js +309 -0
  16. package/src/globals.ts +24 -24
  17. package/{build → src}/index.d.ts +0 -0
  18. package/src/index.js +7 -0
  19. package/{build → src}/itertools.d.ts +4 -0
  20. package/src/itertools.js +98 -0
  21. package/src/itertools.ts +8 -5
  22. package/{build → src}/math.d.ts +1 -1
  23. package/src/math.js +70 -0
  24. package/src/math.ts +5 -1
  25. package/{build → src}/objects.d.ts +0 -0
  26. package/src/objects.js +1 -0
  27. package/{build → src}/operators.d.ts +1 -1
  28. package/src/operators.js +109 -0
  29. package/src/operators.ts +5 -1
  30. package/src/random.d.ts +22 -0
  31. package/src/random.js +48 -0
  32. package/src/random.ts +32 -8
  33. package/{build → src}/strings.d.ts +0 -0
  34. package/src/strings.js +1 -0
  35. package/{build → src}/util.d.ts +0 -0
  36. package/src/util.js +1 -0
  37. package/tests/collections.spec.ts +81 -9
  38. package/tests/globals.spec.ts +44 -4
  39. package/tests/itertools.spec.ts +17 -10
  40. package/tests/operators.spec.ts +8 -5
  41. package/tsconfig.json +17 -3
  42. package/build/collections.js +0 -545
  43. package/build/datetime.js +0 -1
  44. package/build/globals.d.ts +0 -175
  45. package/build/globals.js +0 -332
  46. package/build/index.js +0 -7
  47. package/build/itertools.js +0 -102
  48. package/build/math.js +0 -67
  49. package/build/objects.js +0 -1
  50. package/build/operators.js +0 -128
  51. package/build/random.d.ts +0 -5
  52. package/build/random.js +0 -28
  53. package/build/strings.js +0 -1
  54. package/build/util.js +0 -1
package/.esdoc.json ADDED
@@ -0,0 +1,27 @@
1
+ {
2
+ "source": "./src",
3
+ "destination": "./docs",
4
+ "plugins": [
5
+ {
6
+ "name": "esdoc-standard-plugin",
7
+ "option": {
8
+ "test": {
9
+ "source": "./tests/",
10
+ "interfaces": [
11
+ "describe",
12
+ "it",
13
+ "context",
14
+ "suite",
15
+ "test"
16
+ ],
17
+ "includes": [
18
+ "(spec|Spec|test|Test)\\.ts$"
19
+ ],
20
+ "excludes": [
21
+ "\\.config\\.js$"
22
+ ]
23
+ }
24
+ }
25
+ }
26
+ ]
27
+ }
package/.eslintrc.json CHANGED
@@ -26,6 +26,7 @@
26
26
  "@typescript-eslint/explicit-function-return-type": "off",
27
27
  "@typescript-eslint/no-dynamic-delete": "off",
28
28
  "@typescript-eslint/no-unused-vars": "off",
29
+ "@typescript-eslint/prefer-nullish-coalescing": "off",
29
30
  "@typescript-eslint/restrict-plus-operands": "off",
30
31
  "@typescript-eslint/space-before-function-paren": "off",
31
32
  "@typescript-eslint/strict-boolean-expressions": "off",
package/README.md CHANGED
@@ -2,43 +2,42 @@
2
2
 
3
3
  ## Like Lodash, but for ESNext and with types.
4
4
 
5
- Stop shipping code built for browsers from 2015. Really though, look at the [issues](https://github.com/lodash/lodash/issues/2930#issuecomment-370295020).
5
+ Stop shipping code built for browsers from 2015. Really though, look at the [issues](https://github.com/lodash/lodash/issues/2930).
6
6
 
7
- * Modular: Pick what you need. Works with all bundlers and also supports tree-shaking.
8
- * Native: Uses newer data structures and control flow techniques.
9
- * Lazy: Leverages generators, iterators and functional composition.
10
- * Fluent: Pure functions and abstract classes. Include only what you need.
11
- * TypeScript & JSDoc: Supports both TypeScript and latest JS spec. JSDoc for best in class experience.
7
+ * **Modular**: Pick what you need. Works with all bundlers and also supports tree-shaking.
8
+ * **ESNext**: Uses modern idiomatic syntax, data structures, and control flow techniques.
9
+ * **Lazy**: Leverage generators, iterators, and functional composition.
10
+ * **Fluent**: Pure functions and abstract classes. Include only what you need.
11
+ * **TypeScript & docs**: Includes both type declaration files and js with JSDocs for best in class experience.
12
+
13
+ ## Get Started
12
14
 
13
15
  This library is available as an npm package. To install the package just run:
14
16
 
15
- ```
17
+ ```bash
16
18
  npm install atomic-fns
17
19
  ```
18
20
 
19
21
  ## How to use
20
22
  ```typescript
21
- import { id, reversed, sorted, times, uniqueId } from 'atomic-fns'
23
+ import { reversed, sorted, times, uniqueId } from 'atomic-fns'
22
24
 
23
25
  reverse([1, 2, 3, 4])
24
- // => [4, 3, 2, 1]
26
+ // -> [4, 3, 2, 1]
25
27
 
26
28
  sorted([4, 3, 2, 1])
27
- // => [1, 2, 3, 4]
28
-
29
- times(5, id)
30
- // => [0, 1, 2, 3, 4]
29
+ // -> [1, 2, 3, 4]
31
30
 
32
- times(5, id)
33
- // => [0, 1, 2, 3, 4]
31
+ times(5, (i) => i)
32
+ // -> [0, 1, 2, 3, 4]
34
33
 
35
34
  uniqueId('user_')
36
- // => 'user_101225005'
35
+ // -> 'user_101225005'
37
36
  ```
38
37
 
39
38
  ## Docs
40
39
 
41
- 🛠 Under construction.
40
+ 🚢 Coming soon at [atomic-fns.dev](https://atomic-fns.dev).
42
41
 
43
42
  💡 See the `src` directory for comments.
44
43
 
package/package.json CHANGED
@@ -1,12 +1,14 @@
1
1
  {
2
2
  "name": "atomic-fns",
3
- "description": "A general-purpose and forward looking toolbox for evergreen JS code standards.",
4
- "version": "0.1.1",
5
- "main": "build/index.js",
3
+ "description": "Like Lodash, but for ESNext and with types. Stop shipping code built for browsers from 2015.",
4
+ "version": "0.2.2",
5
+ "main": "src/index.js",
6
6
  "type": "module",
7
7
  "devDependencies": {
8
8
  "@types/jasmine": "^4.3.0",
9
9
  "@typescript-eslint/eslint-plugin": "^5.39.0",
10
+ "esdoc": "^1.1.0",
11
+ "esdoc-standard-plugin": "^1.0.0",
10
12
  "eslint": "^8.25.0",
11
13
  "eslint-config-prettier": "^8.5.0",
12
14
  "eslint-config-standard-with-typescript": "^23.0.0",
@@ -21,32 +23,36 @@
21
23
  "prettier": "^2.7.1",
22
24
  "pretty-quick": "^3.1.3",
23
25
  "ts-node": "^10.4.1",
26
+ "typedoc": "^0.23.16",
24
27
  "typescript": "^4.8.4"
25
28
  },
26
29
  "scripts": {
27
- "postinstall": "npm run tsc",
30
+ "prepublishOnly": "npm test",
28
31
  "test": "NODE_OPTIONS=--loader=ts-node/esm jasmine --config=jasmine.json",
29
32
  "tsc": "tsc -p ./tsconfig.xo.json --declaration",
30
33
  "lint": "eslint src/**",
31
34
  "lint:fix": "eslint src/** --fix",
32
- "format": "prettier --write src/**"
35
+ "build": "npm run tsc && npm run lint:fix",
36
+ "docs": "typedoc --mode modules"
33
37
  },
34
38
  "lint-staged": {
35
39
  "*.ts": "eslint"
36
40
  },
37
41
  "husky": {
38
42
  "hooks": {
39
- "precommit": "npm test && lint-staged && pretty-quick --staged"
43
+ "precommit": "lint-staged && pretty-quick --staged"
40
44
  }
41
45
  },
42
46
  "repository": {
43
47
  "type": "git",
44
- "url": "git+https://github.com/adrian2x/atomic-fns.git"
48
+ "url": "https://github.com/adrian2x/atomic-fns.git"
45
49
  },
46
50
  "keywords": [
47
- "es-next",
51
+ "atomic",
52
+ "atomicfns",
53
+ "atomic-fns",
48
54
  "esnext",
49
- "ecmascript",
55
+ "es-next",
50
56
  "@esnext",
51
57
  "@es-next",
52
58
  "es6",
@@ -56,16 +62,21 @@
56
62
  "es2017",
57
63
  "es2019",
58
64
  "es2020",
65
+ "es2021",
66
+ "es2022",
67
+ "es2023",
68
+ "lodash",
69
+ "lazy",
59
70
  "modules",
60
71
  "stdlib",
61
72
  "core-js",
62
73
  "util",
63
74
  "fp"
64
75
  ],
65
- "author": "Adrian Cruz <adrian2x>",
76
+ "author": "Adrian Cruz <kangoonie@gmail.com>",
66
77
  "license": "Apache-2.0",
67
78
  "bugs": {
68
- "url": "https://github.com/adrian2x/es-next/issues"
79
+ "url": "https://github.com/adrian2x/atomic-fns/issues"
69
80
  },
70
- "homepage": "https://github.com/adrian2x/es-next#readme"
71
- }
81
+ "homepage": "https://github.com/adrian2x/atomic-fns#readme"
82
+ }
@@ -1,18 +1,21 @@
1
- /// <reference path="../src/globals.d.ts" />
1
+ /**
2
+ * Collections
3
+ * @module
4
+ */
2
5
  import { Function, Iteratee } from './globals.js';
3
6
  /**
4
7
  * A container type that provides contains().
5
8
  *
6
- * @export
9
+ *
7
10
  * @interface Container
8
11
  */
9
12
  export interface Container {
10
13
  contains: (x: any) => boolean;
11
14
  }
12
15
  /**
13
- * These are the "rich comparison" methods, as in Python.
16
+ * These are the "rich comparison" methods, inspired by Python operators.
17
+ *
14
18
  *
15
- * @export
16
19
  * @interface Comparable
17
20
  */
18
21
  export interface Comparable {
@@ -33,7 +36,7 @@ export interface Comparable {
33
36
  * A Collection is an iterable container type.
34
37
  * This is an abstract base class for user-defined collection types.
35
38
  *
36
- * @export
39
+ *
37
40
  * @abstract
38
41
  * @class Collection
39
42
  * @implements {Container}
@@ -87,7 +90,7 @@ export interface Reversible<T = unknown> {
87
90
  /**
88
91
  * A sequence is an iterable type with efficient index-based access.
89
92
  *
90
- * @export
93
+ *
91
94
  * @abstract
92
95
  * @class Sequence
93
96
  * @extends {Collection}
@@ -141,6 +144,14 @@ export declare abstract class Sequence<T> extends Collection implements Reversib
141
144
  size(): number;
142
145
  reversed(): Iterator<T>;
143
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
+ */
144
155
  export declare class FrozenSet<T = any> extends Set<T> {
145
156
  constructor(iterable: Iterable<T>);
146
157
  add(): this;
@@ -149,7 +160,20 @@ export declare class FrozenSet<T = any> extends Set<T> {
149
160
  freeze(): Readonly<this>;
150
161
  }
151
162
  export declare const compact: (...arr: any[]) => any[];
152
- export declare function namedtuple(...fields: string[]): (...args: 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[]) => {};
153
177
  export declare function filter(arr: any, fn?: Iteratee | PropertyKey | Object): any[] | undefined;
154
178
  export declare function find(arr: any, fn: Iteratee | PropertyKey | Object): any;
155
179
  export declare function findRight(arr: any, fn: Iteratee | PropertyKey | Object): any;
@@ -168,7 +192,7 @@ export declare function lastIndexOf(obj: any, x: any, start?: any): any;
168
192
  /**
169
193
  * Creates a clone of the given `obj`. If `deep` is `true` it will clone it recursively.
170
194
  *
171
- * @export
195
+ *
172
196
  * @param {*} obj
173
197
  * @param {boolean} [deep=false]
174
198
  * @return The clone value
@@ -184,7 +208,7 @@ export declare function sortedUniq(arr: any, fn?: string | Iteratee): any[];
184
208
  *
185
209
  * Note: this method mutates `obj`
186
210
  *
187
- * @export
211
+ *
188
212
  * @param {Object} obj
189
213
  * @param {...Object} sources
190
214
  * @return {Object} The destination object.
@@ -196,7 +220,7 @@ export declare function union(...args: any[]): Generator<unknown, void, unknown>
196
220
  /**
197
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.
198
222
  *
199
- * @export
223
+ *
200
224
  * @param {(any[] | Object)} arr The collection to iterate over.
201
225
  * @param {(Iteratee | PropertyKey)} [func=id] The iteratee to transform keys.
202
226
  * @return {Object} Returns the composed aggregate object.