atomic-fns 0.3.4 → 0.4.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 (106) hide show
  1. package/README.md +3 -3
  2. package/{core → dist}/collections/BTree.d.ts +6 -6
  3. package/{core → dist}/collections/BTree.js +17 -17
  4. package/{core → dist}/collections/Heap.d.ts +3 -3
  5. package/{core → dist}/collections/Heap.js +0 -0
  6. package/dist/collections/LRUCache.d.ts +80 -0
  7. package/dist/collections/LRUCache.js +126 -0
  8. package/{core → dist}/collections/SortedMap.d.ts +2 -2
  9. package/{core → dist}/collections/SortedMap.js +0 -0
  10. package/{core → dist}/collections/SortedSet.d.ts +3 -3
  11. package/{core → dist}/collections/SortedSet.js +1 -1
  12. package/{core → dist}/collections/SortedTree.d.ts +3 -3
  13. package/{core → dist}/collections/SortedTree.js +1 -1
  14. package/{core → dist}/collections/SplayTree.d.ts +5 -5
  15. package/{core → dist}/collections/SplayTree.js +0 -0
  16. package/{core → dist}/collections/abc.d.ts +1 -1
  17. package/{core → dist}/collections/abc.js +0 -0
  18. package/dist/collections/deque.d.ts +117 -0
  19. package/{core → dist}/collections/deque.js +61 -53
  20. package/{core → dist}/collections/frozenset.d.ts +0 -0
  21. package/{core → dist}/collections/frozenset.js +3 -6
  22. package/{core → dist}/collections/index.d.ts +4 -4
  23. package/{core → dist}/collections/index.js +0 -0
  24. package/{core → dist}/functools/index.d.ts +28 -13
  25. package/{core → dist}/functools/index.js +34 -12
  26. package/{core → dist}/globals/index.d.ts +8 -11
  27. package/{core → dist}/globals/index.js +8 -15
  28. package/dist/i18n/date/index.d.ts +204 -0
  29. package/dist/i18n/date/index.js +530 -0
  30. package/dist/i18n/date/utils.d.ts +65 -0
  31. package/dist/i18n/date/utils.js +312 -0
  32. package/dist/i18n/duration.d.ts +112 -0
  33. package/dist/i18n/duration.js +392 -0
  34. package/dist/i18n/format.d.ts +26 -0
  35. package/dist/i18n/format.js +495 -0
  36. package/{core → dist}/i18n/index.d.ts +1 -1
  37. package/{core → dist}/i18n/index.js +1 -1
  38. package/{core → dist}/index.d.ts +0 -0
  39. package/{core → dist}/index.js +0 -0
  40. package/{core → dist}/itertools/index.d.ts +27 -27
  41. package/{core → dist}/itertools/index.js +24 -24
  42. package/{core → dist}/math/index.d.ts +3 -3
  43. package/{core → dist}/math/index.js +0 -0
  44. package/{core → dist}/operators/index.d.ts +2 -2
  45. package/{core → dist}/operators/index.js +2 -2
  46. package/{core → dist}/random/index.d.ts +1 -1
  47. package/{core → dist}/random/index.js +3 -3
  48. package/package.json +28 -42
  49. package/.editorconfig +0 -12
  50. package/.esdoc.json +0 -27
  51. package/.eslintignore +0 -1
  52. package/.eslintrc.json +0 -35
  53. package/.firebaserc +0 -5
  54. package/.prettierrc +0 -19
  55. package/core/collections/BTree.ts +0 -1340
  56. package/core/collections/Heap.ts +0 -189
  57. package/core/collections/LRUCache.d.ts +0 -152
  58. package/core/collections/LRUCache.js +0 -409
  59. package/core/collections/LRUCache.ts +0 -486
  60. package/core/collections/SortedMap.ts +0 -146
  61. package/core/collections/SortedSet.ts +0 -110
  62. package/core/collections/SortedTree.ts +0 -160
  63. package/core/collections/SplayTree.ts +0 -354
  64. package/core/collections/abc.ts +0 -176
  65. package/core/collections/deque.d.ts +0 -110
  66. package/core/collections/deque.ts +0 -329
  67. package/core/collections/frozenset.ts +0 -37
  68. package/core/collections/index.ts +0 -1024
  69. package/core/collections/test.html +0 -10
  70. package/core/collections/typedArrays.d.ts +0 -31
  71. package/core/collections/typedArrays.js +0 -143
  72. package/core/collections/typedArrays.ts +0 -163
  73. package/core/functools/index.ts +0 -258
  74. package/core/globals/index.ts +0 -481
  75. package/core/i18n/date/format.d.ts +0 -16
  76. package/core/i18n/date/format.js +0 -307
  77. package/core/i18n/date/format.ts +0 -343
  78. package/core/i18n/date/index.d.ts +0 -223
  79. package/core/i18n/date/index.js +0 -387
  80. package/core/i18n/date/index.ts +0 -471
  81. package/core/i18n/date/test.html +0 -67
  82. package/core/i18n/index.ts +0 -8
  83. package/core/index.ts +0 -8
  84. package/core/itertools/index.ts +0 -494
  85. package/core/math/index.ts +0 -152
  86. package/core/operators/index.ts +0 -310
  87. package/core/random/index.ts +0 -66
  88. package/firebase.json +0 -10
  89. package/jasmine.json +0 -14
  90. package/tests/BTree.spec.ts +0 -143
  91. package/tests/Cache.spec.ts +0 -161
  92. package/tests/Heap.spec.ts +0 -66
  93. package/tests/SortedMap.spec.ts +0 -144
  94. package/tests/SortedSet.spec.ts +0 -84
  95. package/tests/SortedTree.spec.ts +0 -164
  96. package/tests/SplayTree.spec.ts +0 -121
  97. package/tests/collections.spec.ts +0 -288
  98. package/tests/deque.spec.ts +0 -107
  99. package/tests/globals.spec.ts +0 -270
  100. package/tests/itertools.spec.ts +0 -266
  101. package/tests/math.spec.ts +0 -25
  102. package/tests/operators.spec.ts +0 -40
  103. package/tests/random.spec.ts +0 -46
  104. package/tsconfig.json +0 -126
  105. package/tsconfig.node.json +0 -18
  106. package/tsconfig.xo.json +0 -9
@@ -34,13 +34,13 @@ export function* accumulate(iterable, func = add, initial) {
34
34
  * @example
35
35
  ```js
36
36
  all([0])
37
- // => true
37
+ // true
38
38
 
39
39
  all([1, 2, 3])
40
- // => true
40
+ // true
41
41
 
42
42
  all([2, 4, 6] => (n) => n > 1)
43
- // => true
43
+ // true
44
44
  ```
45
45
  @see {@link any}
46
46
  */
@@ -59,13 +59,13 @@ export const all = (iterable, fn = bool) => {
59
59
  * @example
60
60
  ```js
61
61
  any([0])
62
- // => false
62
+ // false
63
63
 
64
64
  any([0, 1, null, undefined])
65
- // => true
65
+ // true
66
66
 
67
67
  any([1, 4, 5] => (n) => n % 2 === 0)
68
- // => true
68
+ // true
69
69
  ```
70
70
  @see {@link all}
71
71
  */
@@ -87,16 +87,16 @@ export function chain(...iterables) {
87
87
  * @example
88
88
  ```js
89
89
  contains([1, 2, 3], 1)
90
- // => true
90
+ // true
91
91
 
92
92
  contains([1, 2, 3], 1, 2)
93
- // => false
93
+ // false
94
94
 
95
95
  contains({ 'a': 1, 'b': 2 }, 1)
96
- // => true
96
+ // true
97
97
 
98
98
  contains('abcd', 'bc')
99
- // => true
99
+ // true
100
100
  ```
101
101
  *
102
102
  * @see {@link Collections.find}
@@ -159,11 +159,11 @@ export function IterableIterator(next) {
159
159
  * @example
160
160
  ```js
161
161
  console.log([...enumerate(['hello', 'world'])])
162
- // => [[0, 'hello'], [1, 'world']]
162
+ // [[0, 'hello'], [1, 'world']]
163
163
 
164
164
  // Start with index `1`
165
165
  console.log([...enumerate(['hello', 'world'], 1)])
166
- // => [[1, 'hello'], [2, 'world']]
166
+ // [[1, 'hello'], [2, 'world']]
167
167
  ```
168
168
  */
169
169
  export function* enumerate(iterable, start = 0) {
@@ -187,7 +187,7 @@ export function first(iterable) {
187
187
  * @example
188
188
  ```js
189
189
  compact([0, 1, false, 2, '', 3])
190
- // => [1, 2, 3]
190
+ // [1, 2, 3]
191
191
  ```
192
192
  */
193
193
  export function* icompact(iterable) {
@@ -216,7 +216,7 @@ export function* imap(iterable, mapFn) {
216
216
  * @example
217
217
  ```js
218
218
  [...iflatten([[0, 1], [2, 3]])]
219
- // => [0, 1, 2, 3]
219
+ // [0, 1, 2, 3]
220
220
  ```
221
221
  */
222
222
  export function* iflatten(iterables) {
@@ -287,19 +287,19 @@ export function partition(iterable, predicate) {
287
287
  * @example
288
288
  ```js
289
289
  range(5)
290
- // => [0, 1, 2, 3, 4]
290
+ // [0, 1, 2, 3, 4]
291
291
 
292
292
  range(2, 5)
293
- // => [2, 3, 4]
293
+ // [2, 3, 4]
294
294
 
295
295
  range(0, 5, 2)
296
- // => [0, 2, 4]
296
+ // [0, 2, 4]
297
297
 
298
298
  range(5, 0, -1)
299
- // => [5, 4, 3, 2, 1]
299
+ // [5, 4, 3, 2, 1]
300
300
 
301
301
  range(-3)
302
- // => []
302
+ // []
303
303
  ```
304
304
  */
305
305
  export function* range(...args) {
@@ -333,7 +333,7 @@ export function* range(...args) {
333
333
  * @example
334
334
  ```js
335
335
  reduce([1, 2, 3, 4, 5], (x, y) => x + y, 0)
336
- // => 15
336
+ // 15
337
337
  ```
338
338
  * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce Array.reduce()}
339
339
  */
@@ -407,7 +407,7 @@ export function sort(args, reverse, compareFn) {
407
407
  reverse = false;
408
408
  }
409
409
  args.sort(compareFn || compare);
410
- if (reverse === true)
410
+ if (reverse)
411
411
  args.reverse();
412
412
  return args;
413
413
  }
@@ -445,9 +445,9 @@ export function* times(n, fn) {
445
445
  ```js
446
446
  for item of zip([1, 2, 3], ['sugar', 'spice', 'nice'])
447
447
  console.log(item)
448
- // => [1, 'sugar']
449
- // => [2, 'spice']
450
- // => [3, 'nice']
448
+ // [1, 'sugar']
449
+ // [2, 'spice']
450
+ // [3, 'nice']
451
451
  ```
452
452
  */
453
453
  export function* zip(...args) {
@@ -73,7 +73,7 @@ export declare function max<T>(iterable: Iterable<T>, key?: Predicate<T>): T;
73
73
  let objects = [{ 'n': 4 }, { 'n': 2 }, { 'n': 8 }, { 'n': 6 }]
74
74
 
75
75
  mean(objects, (o) => o.n)
76
- // => 5
76
+ // 5
77
77
  ```
78
78
  */
79
79
  export declare function mean(iterable: number[]): false | number;
@@ -86,10 +86,10 @@ export declare function mean<T>(iterable: Iterable<T>, key?: Predicate<T>): fals
86
86
  * @example
87
87
  ```js
88
88
  sum([1, 2, 3, 4])
89
- // => 10
89
+ // 10
90
90
 
91
91
  sum([1, 2, 3, 4], 5)
92
- // => 15
92
+ // 15
93
93
  ```
94
94
  */
95
95
  export declare function sum(iterable: number[]): number;
File without changes
@@ -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 eq}
39
- * @see {@link lt}
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
  /**
@@ -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 eq}
40
- * @see {@link lt}
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))
@@ -22,7 +22,7 @@ export declare const randomInt: (min?: number, max?: number) => number;
22
22
  * @returns {T}
23
23
  * @template T
24
24
  */
25
- export declare const choice: <T>(arr: T[]) => T | undefined;
25
+ export declare const choice: <T>(arr: T[]) => T;
26
26
  /**
27
27
  * Returns a random sample of size k from a list of items.
28
28
  * @param {Array} arr
@@ -24,7 +24,7 @@ export const randomInt = (min = 0, max = 1) => Math.round(random(min, max));
24
24
  * @template T
25
25
  */
26
26
  export const choice = (arr) => {
27
- if (!arr || !arr.length)
27
+ if (!arr?.length)
28
28
  return;
29
29
  return arr[randomInt(0, arr.length - 1)];
30
30
  };
@@ -36,7 +36,7 @@ export const choice = (arr) => {
36
36
  * @template T
37
37
  */
38
38
  export function sample(arr, size) {
39
- if (!arr || !arr.length || arr.length < size)
39
+ if (!arr?.length || arr.length < size)
40
40
  return [];
41
41
  return shuffle(arr.slice()).slice(-size);
42
42
  }
@@ -49,7 +49,7 @@ export function sample(arr, size) {
49
49
  * @template T
50
50
  */
51
51
  export function shuffle(arr, size) {
52
- if (!arr || !arr.length)
52
+ if (!arr?.length)
53
53
  return arr;
54
54
  if (isObject(arr))
55
55
  arr = Object.values(arr);
package/package.json CHANGED
@@ -1,20 +1,22 @@
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": "0.3.4",
5
- "main": "core/index.js",
4
+ "version": "0.4.2",
5
+ "files": [
6
+ "dist/*"
7
+ ],
6
8
  "type": "module",
7
- "types": "core/index.d.ts",
8
- "module": "core/index.js",
9
+ "module": "dist/index.js",
10
+ "main": "dist/index.js",
11
+ "types": "dist/index.d.ts",
9
12
  "sideEffects": false,
10
13
  "scripts": {
11
- "prepublishOnly": "npm test",
14
+ "prepublishOnly": "npm run build",
12
15
  "test": "NODE_OPTIONS=--loader=ts-node/esm jasmine --config=jasmine.json",
13
- "tsc": "tsc -p ./tsconfig.xo.json --declaration",
14
- "tsc:w": "tsc -p ./tsconfig.xo.json --declaration --watch",
15
- "lint": "eslint core/**/*.ts",
16
- "lint:fix": "eslint core/**/*.ts --fix",
17
- "build": "npm run lint:fix && npm run tsc && npm run docs",
16
+ "tsc": "tsc -p . --declaration",
17
+ "tsc:w": "tsc -p . --declaration --watch",
18
+ "lint": "eslint src/**/*.ts --fix",
19
+ "build": "npm run lint && npm test && npm run tsc",
18
20
  "docs": "typedoc"
19
21
  },
20
22
  "devDependencies": {
@@ -23,40 +25,29 @@
23
25
  "eslint": "^8.25.0",
24
26
  "eslint-config-prettier": "^8.5.0",
25
27
  "eslint-config-standard-with-typescript": "^23.0.0",
26
- "eslint-plugin-import": "^2.26.0",
27
28
  "eslint-plugin-n": "^15.3.0",
28
29
  "eslint-plugin-prettier": "^4.2.1",
29
- "eslint-plugin-promise": "^6.0.1",
30
- "husky": "^8.0.1",
31
30
  "jasmine": "^4.4.0",
32
31
  "jasmine-spec-reporter": "^7.0.0",
33
- "lint-staged": "^13.0.3",
34
32
  "prettier": "^2.7.1",
35
- "pretty-quick": "^3.1.3",
36
- "ts-node": "^10.4.1",
33
+ "ts-node": "^10.9.1",
37
34
  "typedoc": "^0.23.16",
38
35
  "typescript": "^4.8.4"
39
36
  },
40
- "lint-staged": {
41
- "*.ts": "eslint --fix"
42
- },
43
- "husky": {
44
- "hooks": {
45
- "precommit": "lint-staged && pretty-quick --staged"
46
- }
47
- },
48
37
  "repository": {
49
38
  "type": "git",
50
39
  "url": "https://github.com/adrian2x/atomic-fns.git"
51
40
  },
52
41
  "keywords": [
53
- "atomic",
54
- "atomicfns",
55
- "atomic-fns",
56
- "esnext",
57
- "es-next",
58
- "@esnext",
59
- "@es-next",
42
+ "modules",
43
+ "stdlib",
44
+ "util",
45
+ "fp",
46
+ "lazy",
47
+ "itertools",
48
+ "core-js",
49
+ "lodash",
50
+ "lodash-es",
60
51
  "es6",
61
52
  "es7",
62
53
  "es8",
@@ -64,17 +55,12 @@
64
55
  "es2020",
65
56
  "es2021",
66
57
  "es2022",
67
- "es2023",
68
- "lodash",
69
- "lodash-es",
70
- "itertools",
71
- "lazy",
72
- "module",
73
- "modules",
74
- "stdlib",
75
- "core-js",
76
- "util",
77
- "fp"
58
+ "esnext",
59
+ "es-next",
60
+ "@esnext",
61
+ "@es-next",
62
+ "atomicfns",
63
+ "atomic-fns"
78
64
  ],
79
65
  "author": "Adrian Cruz <kangoonie@gmail.com>",
80
66
  "license": "Apache-2.0",
package/.editorconfig DELETED
@@ -1,12 +0,0 @@
1
- # EditorConfig is awesome: https://EditorConfig.org
2
-
3
- # top-most EditorConfig file
4
- root = true
5
-
6
- [*]
7
- indent_style = space
8
- indent_size = 2
9
- end_of_line = lf
10
- charset = utf-8
11
- trim_trailing_whitespace = true
12
- insert_final_newline = true
package/.esdoc.json DELETED
@@ -1,27 +0,0 @@
1
- {
2
- "source": "./lib",
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/.eslintignore DELETED
@@ -1 +0,0 @@
1
- *.d.ts
package/.eslintrc.json DELETED
@@ -1,35 +0,0 @@
1
- {
2
- "env": {
3
- "browser": true,
4
- "es2021": true
5
- },
6
- "extends": [
7
- "standard-with-typescript",
8
- "plugin:prettier/recommended"
9
- ],
10
- "overrides": [
11
- {
12
- "files": [
13
- "*.ts",
14
- "*.tsx"
15
- ]
16
- }
17
- ],
18
- "parserOptions": {
19
- "project": [
20
- "./tsconfig.xo.json"
21
- ],
22
- "ecmaVersion": "latest",
23
- "sourceType": "module"
24
- },
25
- "rules": {
26
- "@typescript-eslint/explicit-function-return-type": "off",
27
- "@typescript-eslint/no-dynamic-delete": "off",
28
- "@typescript-eslint/no-unused-vars": "off",
29
- "@typescript-eslint/prefer-nullish-coalescing": "off",
30
- "@typescript-eslint/restrict-plus-operands": "off",
31
- "@typescript-eslint/space-before-function-paren": "off",
32
- "@typescript-eslint/strict-boolean-expressions": "off",
33
- "@typescript-eslint/triple-slash-reference": "off"
34
- }
35
- }
package/.firebaserc DELETED
@@ -1,5 +0,0 @@
1
- {
2
- "projects": {
3
- "default": "atomic-fns"
4
- }
5
- }
package/.prettierrc DELETED
@@ -1,19 +0,0 @@
1
- {
2
- "arrowParens": "always",
3
- "bracketSameLine": true,
4
- "bracketSpacing": true,
5
- "embeddedLanguageFormatting": "auto",
6
- "endOfLine": "lf",
7
- "htmlWhitespaceSensitivity": "css",
8
- "insertPragma": false,
9
- "printWidth": 100,
10
- "proseWrap": "preserve",
11
- "quoteProps": "as-needed",
12
- "requirePragma": false,
13
- "semi": false,
14
- "singleQuote": true,
15
- "jsxSingleQuote": true,
16
- "trailingComma": "none",
17
- "tabWidth": 2,
18
- "useTabs": false
19
- }