aneka 0.13.1 → 0.15.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 (127) hide show
  1. package/.jsdoc.conf.json +39 -0
  2. package/CHANGES.md +8 -0
  3. package/README.md +64 -1
  4. package/docs/arrange-array.js.html +28 -0
  5. package/docs/create-class.js.html +38 -0
  6. package/docs/current-loc.js.html +34 -0
  7. package/docs/data/search.json +1 -0
  8. package/docs/defaults-deep.js.html +23 -0
  9. package/docs/delay.js.html +19 -0
  10. package/docs/extract-text.js.html +26 -0
  11. package/docs/fill-object.js.html +20 -0
  12. package/docs/filter-duplicate.js.html +29 -0
  13. package/docs/filter-index.js.html +20 -0
  14. package/docs/fonts/Inconsolata-Regular.ttf +0 -0
  15. package/docs/fonts/OpenSans-Regular.ttf +0 -0
  16. package/docs/fonts/WorkSans-Bold.ttf +0 -0
  17. package/docs/format-text.js.html +91 -0
  18. package/docs/generate-id.js.html +38 -0
  19. package/docs/get-caller-filename.js.html +28 -0
  20. package/docs/get-index.js.html +18 -0
  21. package/docs/get-key-by-value.js.html +15 -0
  22. package/docs/global.html +12 -0
  23. package/docs/includes.js.html +21 -0
  24. package/docs/index.html +17 -0
  25. package/docs/is-class.js.html +16 -0
  26. package/docs/is-set.js.html +14 -0
  27. package/docs/merge-objects-by-key.js.html +27 -0
  28. package/docs/paginate.js.html +48 -0
  29. package/docs/parse-args-argv.js.html +85 -0
  30. package/docs/parse-duration.js.html +17 -0
  31. package/docs/parse-env.js.html +50 -0
  32. package/docs/parse-kv-string.js.html +24 -0
  33. package/docs/parse-object.js.html +79 -0
  34. package/docs/pascal-case.js.html +17 -0
  35. package/docs/random-range.js.html +18 -0
  36. package/docs/resolve-path.js.html +26 -0
  37. package/docs/round.js.html +16 -0
  38. package/docs/scripts/core.js +726 -0
  39. package/docs/scripts/core.min.js +23 -0
  40. package/docs/scripts/resize.js +90 -0
  41. package/docs/scripts/search.js +265 -0
  42. package/docs/scripts/search.min.js +6 -0
  43. package/docs/scripts/third-party/Apache-License-2.0.txt +202 -0
  44. package/docs/scripts/third-party/fuse.js +9 -0
  45. package/docs/scripts/third-party/hljs-line-num-original.js +369 -0
  46. package/docs/scripts/third-party/hljs-line-num.js +1 -0
  47. package/docs/scripts/third-party/hljs-original.js +5171 -0
  48. package/docs/scripts/third-party/hljs.js +1 -0
  49. package/docs/scripts/third-party/popper.js +5 -0
  50. package/docs/scripts/third-party/tippy.js +1 -0
  51. package/docs/scripts/third-party/tocbot.js +672 -0
  52. package/docs/scripts/third-party/tocbot.min.js +1 -0
  53. package/docs/sec-to-hms.js.html +30 -0
  54. package/docs/set-immediate.js.html +15 -0
  55. package/docs/shim.js.html +31 -0
  56. package/docs/static/bitcoin.jpeg +0 -0
  57. package/docs/styles/clean-jsdoc-theme-base.css +1159 -0
  58. package/docs/styles/clean-jsdoc-theme-dark.css +412 -0
  59. package/docs/styles/clean-jsdoc-theme-light.css +482 -0
  60. package/docs/styles/clean-jsdoc-theme-scrollbar.css +30 -0
  61. package/docs/styles/clean-jsdoc-theme-without-scrollbar.min.css +1 -0
  62. package/docs/styles/clean-jsdoc-theme.min.css +1 -0
  63. package/docs/text-to-array.js.html +20 -0
  64. package/docs/titleize.js.html +40 -0
  65. package/docs/without.js.html +21 -0
  66. package/index.js +3 -0
  67. package/package.json +7 -2
  68. package/src/arrange-array.js +7 -0
  69. package/src/create-class.js +8 -0
  70. package/src/defaults-deep.js +6 -0
  71. package/src/delay.js +6 -0
  72. package/src/extract-text.js +8 -0
  73. package/src/get-caller-filename.js +25 -0
  74. package/src/get-index.js +7 -0
  75. package/src/get-key-by-value.js +7 -0
  76. package/src/includes.js +7 -0
  77. package/src/is-class.js +6 -0
  78. package/src/is-set.js +6 -0
  79. package/src/merge-objects-by-key.js +7 -0
  80. package/src/paginate.js +17 -1
  81. package/src/parse-kv-string.js +8 -0
  82. package/src/parse-object.js +15 -10
  83. package/src/pascal-case.js +6 -0
  84. package/src/random-range.js +5 -5
  85. package/src/resolve-path.js +2 -2
  86. package/src/round.js +7 -0
  87. package/src/sec-to-hms.js +7 -0
  88. package/src/set-immediate.js +3 -1
  89. package/src/shim.js +3 -5
  90. package/src/text-to-array.js +6 -0
  91. package/src/titleize.js +11 -1
  92. package/src/without.js +10 -0
  93. package/test/arrange-array.js +41 -0
  94. package/test/create-class.js +33 -0
  95. package/test/current-loc.js +24 -0
  96. package/test/defaults-deep.js +19 -0
  97. package/test/delay.js +17 -0
  98. package/test/extract-text.js +17 -0
  99. package/test/fill-object.js +17 -0
  100. package/test/filter-duplicate.js +11 -16
  101. package/test/filter-index.js +9 -16
  102. package/test/format-text.js +26 -0
  103. package/test/generate-id.js +28 -0
  104. package/test/get-caller-filename.js +22 -0
  105. package/test/get-index.js +17 -0
  106. package/test/get-key-by-value.js +17 -0
  107. package/test/includes.js +18 -0
  108. package/test/is-class.js +19 -0
  109. package/test/is-set.js +21 -0
  110. package/test/log.js +47 -0
  111. package/test/merge-objects-by-key.js +13 -15
  112. package/test/paginate.js +24 -0
  113. package/test/parse-args-argv.js +63 -0
  114. package/test/parse-duration.js +18 -0
  115. package/test/parse-env.js +35 -0
  116. package/test/parse-kv-string.js +11 -5
  117. package/test/parse-object.js +24 -4
  118. package/test/pascal-case.js +18 -0
  119. package/test/random-range.js +21 -0
  120. package/test/resolve-path.js +22 -0
  121. package/test/round.js +19 -0
  122. package/test/sec-to-hms.js +18 -0
  123. package/test/set-immediate.js +17 -0
  124. package/test/shim.js +34 -0
  125. package/test/text-to-array.js +18 -0
  126. package/test/titleize.js +27 -0
  127. package/test/without.js +17 -0
@@ -1,11 +1,17 @@
1
+ /* eslint-env mocha */
1
2
  import { expect } from 'chai'
2
3
  import fn from '../src/parse-kv-string.js'
3
4
 
4
5
  describe('parseKvString', function () {
5
- it('Should return the expected result', function () {
6
- const items = { ONE: 1, TWO: ['one', 'two'] }
7
- const input = 'ONE=1\nTWO=one,two'
8
- const result = fn(input)
9
- expect(result).to.eql(items)
6
+ it('parses key-value text into typed object', function () {
7
+ expect(fn('A=1|B=true|C=text')).to.deep.equal({ A: 1, B: true, C: 'text' })
8
+ })
9
+
10
+ it('supports custom line delimiters', function () {
11
+ expect(fn('A=1;B=2', true, ';')).to.deep.equal({ A: 1, B: 2 })
12
+ })
13
+
14
+ it('respects trimValue=false', function () {
15
+ expect(fn('A= hello ', false)).to.deep.equal({ A: ' hello ' })
10
16
  })
11
17
  })
@@ -1,10 +1,30 @@
1
+ /* eslint-env mocha */
1
2
  import { expect } from 'chai'
2
3
  import fn from '../src/parse-object.js'
3
4
 
4
5
  describe('parseObject', function () {
5
- it('Should return the expected result', function () {
6
- const items = { _: { log: { pretty: true, level: 'trace' }, lang: 'id' } }
7
- const result = fn(items, { parseValue: true })
8
- expect(result).to.eql(items)
6
+ it('parses nested values recursively', function () {
7
+ const out = fn({ num: '1', nested: { ok: 'true' }, ttlDur: '2s' }, { parseValue: true })
8
+ expect(out.num).to.equal(1)
9
+ expect(out.nested.ok).to.equal(true)
10
+ expect(out.ttlDur).to.equal(2000)
11
+ })
12
+
13
+ it('accepts JSON string input', function () {
14
+ const out = fn('{"enabled":"true","count":"2"}', { parseValue: true })
15
+ expect(out).to.deep.equal({ enabled: true, count: 2 })
16
+ })
17
+
18
+ it('throws invalid json when silent is false', function () {
19
+ expect(() => fn('{ bad', { silent: false })).to.throw()
20
+ })
21
+
22
+ it('returns empty object for invalid json when silent is true', function () {
23
+ expect(fn('{ bad', { silent: true })).to.deep.equal({})
24
+ })
25
+
26
+ it('keeps static wildcard values unchanged', function () {
27
+ const out = fn({ marker: '*', nested: { marker: '*' } }, { parseValue: true })
28
+ expect(out).to.deep.equal({ marker: '*', nested: { marker: '*' } })
9
29
  })
10
30
  })
@@ -0,0 +1,18 @@
1
+ /* eslint-env mocha */
2
+ import { expect } from 'chai'
3
+ import fn from '../src/pascal-case.js'
4
+
5
+ describe('pascalCase', function () {
6
+ it('converts text to PascalCase', function () {
7
+ expect(fn('hello world')).to.equal('HelloWorld')
8
+ })
9
+
10
+ it('handles snake and kebab case input', function () {
11
+ expect(fn('hello_world')).to.equal('HelloWorld')
12
+ expect(fn('hello-world')).to.equal('HelloWorld')
13
+ })
14
+
15
+ it('handles already-camelized input', function () {
16
+ expect(fn('helloWorld')).to.equal('HelloWorld')
17
+ })
18
+ })
@@ -0,0 +1,21 @@
1
+ /* eslint-env mocha */
2
+ import { expect } from 'chai'
3
+ import fn from '../src/random-range.js'
4
+
5
+ describe('randomRange', function () {
6
+ it('returns number and alpha values in expected range', function () {
7
+ const n = fn(1, 3)
8
+ expect(n).to.be.within(1, 3)
9
+
10
+ const ch = fn(1, 26, true)
11
+ expect(ch).to.match(/^[a-z]$/)
12
+ })
13
+
14
+ it('returns deterministic value when min equals max', function () {
15
+ expect(fn(5, 5)).to.equal(5)
16
+ })
17
+
18
+ it('returns expected alpha character when min equals max', function () {
19
+ expect(fn(1, 1, true)).to.equal('a')
20
+ })
21
+ })
@@ -0,0 +1,22 @@
1
+ /* eslint-env mocha */
2
+ import { expect } from 'chai'
3
+ import path from 'path'
4
+ import fn from '../src/resolve-path.js'
5
+
6
+ describe('resolvePath', function () {
7
+ it('resolves paths and can return file URL', function () {
8
+ const resolved = fn('./src/../src/round.js')
9
+ expect(path.isAbsolute(resolved)).to.equal(true)
10
+ const asUrl = fn('./src/round.js', true)
11
+ expect(asUrl.startsWith('file:///')).to.equal(true)
12
+ })
13
+
14
+ it('resolves file urls back to absolute paths', function () {
15
+ const pathValue = fn('file:///tmp/example.txt')
16
+ expect(path.isAbsolute(pathValue)).to.equal(true)
17
+ })
18
+
19
+ it('returns absolute path for relative input', function () {
20
+ expect(path.isAbsolute(fn('./README.md'))).to.equal(true)
21
+ })
22
+ })
package/test/round.js ADDED
@@ -0,0 +1,19 @@
1
+ /* eslint-env mocha */
2
+ import { expect } from 'chai'
3
+ import fn from '../src/round.js'
4
+
5
+ describe('round', function () {
6
+ it('rounds numeric values with scale', function () {
7
+ expect(fn(1.2345, 2)).to.equal(1.23)
8
+ expect(fn(1.9)).to.equal(2)
9
+ })
10
+
11
+ it('uses integer rounding when scale is zero or negative', function () {
12
+ expect(fn(1.49, 0)).to.equal(1)
13
+ expect(fn(1.51, -3)).to.equal(2)
14
+ })
15
+
16
+ it('handles negative numbers', function () {
17
+ expect(fn(-1.234, 2)).to.equal(-1.23)
18
+ })
19
+ })
@@ -0,0 +1,18 @@
1
+ /* eslint-env mocha */
2
+ import { expect } from 'chai'
3
+ import fn from '../src/sec-to-hms.js'
4
+
5
+ describe('secToHms', function () {
6
+ it('formats seconds and milliseconds', function () {
7
+ expect(fn(61)).to.equal('01:01')
8
+ expect(fn(12345, true)).to.equal('00:12+345')
9
+ })
10
+
11
+ it('includes hours for long durations', function () {
12
+ expect(fn(3661)).to.equal('01:01:01')
13
+ })
14
+
15
+ it('formats zero as 00:00', function () {
16
+ expect(fn(0)).to.equal('00:00')
17
+ })
18
+ })
@@ -0,0 +1,17 @@
1
+ /* eslint-env mocha */
2
+ import { expect } from 'chai'
3
+ import fn from '../src/set-immediate.js'
4
+
5
+ describe('setImmediate', function () {
6
+ it('exports a callable function', function () {
7
+ expect(fn).to.be.a('function')
8
+ })
9
+
10
+ it('takes no required parameters', function () {
11
+ expect(fn.length).to.equal(0)
12
+ })
13
+
14
+ it('is declared as async function', function () {
15
+ expect(fn.constructor.name).to.equal('AsyncFunction')
16
+ })
17
+ })
package/test/shim.js ADDED
@@ -0,0 +1,34 @@
1
+ /* eslint-env mocha */
2
+ import { expect } from 'chai'
3
+ import fn from '../src/shim.js'
4
+
5
+ describe('shim', function () {
6
+ it('adds splice polyfill when missing', function () {
7
+ const oldSplice = String.prototype.splice
8
+ delete String.prototype.splice
9
+ try {
10
+ fn()
11
+ expect('abcd'.splice(1, 2, 'X')).to.equal('aXd')
12
+ } finally {
13
+ if (oldSplice) String.prototype.splice = oldSplice
14
+ else delete String.prototype.splice
15
+ }
16
+ })
17
+
18
+ it('can add replaceAll polyfill when missing', function () {
19
+ const oldReplaceAll = String.prototype.replaceAll
20
+ delete String.prototype.replaceAll
21
+ try {
22
+ fn()
23
+ expect('abca'.replaceAll('a', 'x')).to.equal('xbcx')
24
+ } finally {
25
+ if (oldReplaceAll) String.prototype.replaceAll = oldReplaceAll
26
+ else delete String.prototype.replaceAll
27
+ }
28
+ })
29
+
30
+ it('can be called repeatedly without throwing', function () {
31
+ expect(() => fn()).to.not.throw()
32
+ expect(() => fn()).to.not.throw()
33
+ })
34
+ })
@@ -0,0 +1,18 @@
1
+ /* eslint-env mocha */
2
+ import { expect } from 'chai'
3
+ import fn from '../src/text-to-array.js'
4
+
5
+ describe('textToArray', function () {
6
+ it('removes blank lines and comment-only lines', function () {
7
+ const out = fn('a\n# only comment\n b # keep\n\n c')
8
+ expect(out).to.deep.equal(['a', 'b # keep', 'c'])
9
+ })
10
+
11
+ it('trims surrounding spaces from each line', function () {
12
+ expect(fn(' a \n b ')).to.deep.equal(['a', 'b'])
13
+ })
14
+
15
+ it('returns empty array when input has only comments and blanks', function () {
16
+ expect(fn('\n# c\n # d\n')).to.deep.equal([])
17
+ })
18
+ })
@@ -0,0 +1,27 @@
1
+ /* eslint-env mocha */
2
+ import { expect } from 'chai'
3
+ import fn from '../src/titleize.js'
4
+
5
+ describe('titleize', function () {
6
+ it('converts text to title-case output', function () {
7
+ expect(fn('the captain of the sea')).to.equal('The Captain of The Sea')
8
+ })
9
+
10
+ it('keeps ignored words unchanged when configured', function () {
11
+ expect(fn('go to mars', { ignores: ['to'] })).to.equal('Go to Mars')
12
+ })
13
+
14
+ it('supports replacement map before title conversion', function () {
15
+ const out = fn('hello usa', { replacement: { usa: 'USA' } })
16
+ expect(out).to.be.a('string')
17
+ expect(out.startsWith('Hello')).to.equal(true)
18
+ })
19
+
20
+ it('returns empty string for empty input', function () {
21
+ expect(fn('')).to.equal('')
22
+ })
23
+
24
+ it('keeps default ignored words (and/of/or/with) in lowercase', function () {
25
+ expect(fn('king of sea and sky')).to.equal('King of Sea and Sky')
26
+ })
27
+ })
@@ -0,0 +1,17 @@
1
+ /* eslint-env mocha */
2
+ import { expect } from 'chai'
3
+ import fn from '../src/without.js'
4
+
5
+ describe('without', function () {
6
+ it('removes provided and empty-like values', function () {
7
+ expect(fn([1, 2, null, '', 3, undefined], 2)).to.deep.equal([1, 3])
8
+ })
9
+
10
+ it('removes null, undefined and empty string by default', function () {
11
+ expect(fn([null, undefined, '', 'x'])).to.deep.equal(['x'])
12
+ })
13
+
14
+ it('returns empty array for empty input', function () {
15
+ expect(fn([])).to.deep.equal([])
16
+ })
17
+ })