aneka 0.14.0 → 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.
- package/.jsdoc.conf.json +39 -0
- package/CHANGES.md +4 -0
- package/README.md +64 -1
- package/docs/arrange-array.js.html +28 -0
- package/docs/create-class.js.html +38 -0
- package/docs/current-loc.js.html +34 -0
- package/docs/data/search.json +1 -0
- package/docs/defaults-deep.js.html +23 -0
- package/docs/delay.js.html +19 -0
- package/docs/extract-text.js.html +26 -0
- package/docs/fill-object.js.html +20 -0
- package/docs/filter-duplicate.js.html +29 -0
- package/docs/filter-index.js.html +20 -0
- package/docs/fonts/Inconsolata-Regular.ttf +0 -0
- package/docs/fonts/OpenSans-Regular.ttf +0 -0
- package/docs/fonts/WorkSans-Bold.ttf +0 -0
- package/docs/format-text.js.html +91 -0
- package/docs/generate-id.js.html +38 -0
- package/docs/get-caller-filename.js.html +28 -0
- package/docs/get-index.js.html +18 -0
- package/docs/get-key-by-value.js.html +15 -0
- package/docs/global.html +12 -0
- package/docs/includes.js.html +21 -0
- package/docs/index.html +17 -0
- package/docs/is-class.js.html +16 -0
- package/docs/is-set.js.html +14 -0
- package/docs/merge-objects-by-key.js.html +27 -0
- package/docs/paginate.js.html +48 -0
- package/docs/parse-args-argv.js.html +85 -0
- package/docs/parse-duration.js.html +17 -0
- package/docs/parse-env.js.html +50 -0
- package/docs/parse-kv-string.js.html +24 -0
- package/docs/parse-object.js.html +79 -0
- package/docs/pascal-case.js.html +17 -0
- package/docs/random-range.js.html +18 -0
- package/docs/resolve-path.js.html +26 -0
- package/docs/round.js.html +16 -0
- package/docs/scripts/core.js +726 -0
- package/docs/scripts/core.min.js +23 -0
- package/docs/scripts/resize.js +90 -0
- package/docs/scripts/search.js +265 -0
- package/docs/scripts/search.min.js +6 -0
- package/docs/scripts/third-party/Apache-License-2.0.txt +202 -0
- package/docs/scripts/third-party/fuse.js +9 -0
- package/docs/scripts/third-party/hljs-line-num-original.js +369 -0
- package/docs/scripts/third-party/hljs-line-num.js +1 -0
- package/docs/scripts/third-party/hljs-original.js +5171 -0
- package/docs/scripts/third-party/hljs.js +1 -0
- package/docs/scripts/third-party/popper.js +5 -0
- package/docs/scripts/third-party/tippy.js +1 -0
- package/docs/scripts/third-party/tocbot.js +672 -0
- package/docs/scripts/third-party/tocbot.min.js +1 -0
- package/docs/sec-to-hms.js.html +30 -0
- package/docs/set-immediate.js.html +15 -0
- package/docs/shim.js.html +31 -0
- package/docs/static/bitcoin.jpeg +0 -0
- package/docs/styles/clean-jsdoc-theme-base.css +1159 -0
- package/docs/styles/clean-jsdoc-theme-dark.css +412 -0
- package/docs/styles/clean-jsdoc-theme-light.css +482 -0
- package/docs/styles/clean-jsdoc-theme-scrollbar.css +30 -0
- package/docs/styles/clean-jsdoc-theme-without-scrollbar.min.css +1 -0
- package/docs/styles/clean-jsdoc-theme.min.css +1 -0
- package/docs/text-to-array.js.html +20 -0
- package/docs/titleize.js.html +40 -0
- package/docs/without.js.html +21 -0
- package/package.json +7 -2
- package/src/arrange-array.js +7 -0
- package/src/create-class.js +8 -0
- package/src/defaults-deep.js +6 -0
- package/src/delay.js +6 -0
- package/src/extract-text.js +8 -0
- package/src/get-caller-filename.js +5 -0
- package/src/get-index.js +7 -0
- package/src/get-key-by-value.js +7 -0
- package/src/includes.js +7 -0
- package/src/is-class.js +6 -0
- package/src/is-set.js +6 -0
- package/src/merge-objects-by-key.js +7 -0
- package/src/paginate.js +17 -1
- package/src/parse-kv-string.js +8 -0
- package/src/parse-object.js +15 -10
- package/src/pascal-case.js +6 -0
- package/src/random-range.js +5 -5
- package/src/resolve-path.js +2 -2
- package/src/round.js +7 -0
- package/src/sec-to-hms.js +7 -0
- package/src/set-immediate.js +3 -1
- package/src/shim.js +3 -5
- package/src/text-to-array.js +6 -0
- package/src/titleize.js +11 -1
- package/src/without.js +10 -0
- package/test/arrange-array.js +41 -0
- package/test/create-class.js +33 -0
- package/test/current-loc.js +24 -0
- package/test/defaults-deep.js +19 -0
- package/test/delay.js +17 -0
- package/test/extract-text.js +17 -0
- package/test/fill-object.js +17 -0
- package/test/filter-duplicate.js +11 -16
- package/test/filter-index.js +9 -16
- package/test/format-text.js +26 -0
- package/test/generate-id.js +28 -0
- package/test/get-caller-filename.js +22 -0
- package/test/get-index.js +17 -0
- package/test/get-key-by-value.js +17 -0
- package/test/includes.js +18 -0
- package/test/is-class.js +19 -0
- package/test/is-set.js +21 -0
- package/test/log.js +47 -0
- package/test/merge-objects-by-key.js +13 -15
- package/test/paginate.js +24 -0
- package/test/parse-args-argv.js +63 -0
- package/test/parse-duration.js +18 -0
- package/test/parse-env.js +35 -0
- package/test/parse-kv-string.js +11 -5
- package/test/parse-object.js +24 -4
- package/test/pascal-case.js +18 -0
- package/test/random-range.js +21 -0
- package/test/resolve-path.js +22 -0
- package/test/round.js +19 -0
- package/test/sec-to-hms.js +18 -0
- package/test/set-immediate.js +17 -0
- package/test/shim.js +34 -0
- package/test/text-to-array.js +18 -0
- package/test/titleize.js +27 -0
- package/test/without.js +17 -0
|
@@ -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
|
+
})
|
package/test/titleize.js
ADDED
|
@@ -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
|
+
})
|
package/test/without.js
ADDED
|
@@ -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
|
+
})
|