aneka 0.17.6 → 0.17.7
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 +0 -0
- package/CHANGES.md +87 -83
- package/LICENSE +21 -21
- package/README.md +63 -63
- package/docs/arrange-array.js.html +0 -0
- package/docs/create-class.js.html +0 -0
- package/docs/current-loc.js.html +0 -0
- package/docs/data/search.json +0 -0
- package/docs/defaults-deep.js.html +0 -0
- package/docs/delay.js.html +0 -0
- package/docs/extract-text.js.html +0 -0
- package/docs/fill-object.js.html +0 -0
- package/docs/filter-duplicate.js.html +0 -0
- package/docs/filter-index.js.html +0 -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 +0 -0
- package/docs/generate-id.js.html +0 -0
- package/docs/get-caller-filename.js.html +0 -0
- package/docs/get-global-module-dir.js.html +0 -0
- package/docs/get-index.js.html +0 -0
- package/docs/get-key-by-value.js.html +0 -0
- package/docs/global.html +0 -0
- package/docs/includes.js.html +0 -0
- package/docs/index.html +0 -0
- package/docs/is-class.js.html +0 -0
- package/docs/is-set.js.html +0 -0
- package/docs/merge-objects-by-key.js.html +0 -0
- package/docs/paginate.js.html +0 -0
- package/docs/parse-args-argv.js.html +0 -0
- package/docs/parse-duration.js.html +0 -0
- package/docs/parse-env.js.html +0 -0
- package/docs/parse-kv-string.js.html +0 -0
- package/docs/parse-object.js.html +0 -0
- package/docs/pascal-case.js.html +0 -0
- package/docs/random-range.js.html +0 -0
- package/docs/resolve-path.js.html +0 -0
- package/docs/round.js.html +0 -0
- package/docs/scripts/core.js +0 -0
- package/docs/scripts/core.min.js +0 -0
- package/docs/scripts/resize.js +0 -0
- package/docs/scripts/search.js +0 -0
- package/docs/scripts/search.min.js +5 -5
- package/docs/scripts/third-party/Apache-License-2.0.txt +0 -0
- package/docs/scripts/third-party/fuse.js +0 -0
- package/docs/scripts/third-party/hljs-line-num-original.js +0 -0
- package/docs/scripts/third-party/hljs-line-num.js +0 -0
- package/docs/scripts/third-party/hljs-original.js +0 -0
- package/docs/scripts/third-party/hljs.js +0 -0
- package/docs/scripts/third-party/popper.js +0 -0
- package/docs/scripts/third-party/tippy.js +0 -0
- package/docs/scripts/third-party/tocbot.js +0 -0
- package/docs/scripts/third-party/tocbot.min.js +0 -0
- package/docs/sec-to-hms.js.html +0 -0
- package/docs/set-immediate.js.html +0 -0
- package/docs/set-interval.js.html +0 -0
- package/docs/set-timeout.js.html +0 -0
- package/docs/shim.js.html +0 -0
- package/docs/static/bitcoin.jpeg +0 -0
- package/docs/styles/clean-jsdoc-theme-base.css +0 -0
- package/docs/styles/clean-jsdoc-theme-dark.css +0 -0
- package/docs/styles/clean-jsdoc-theme-light.css +0 -0
- package/docs/styles/clean-jsdoc-theme-scrollbar.css +0 -0
- package/docs/styles/clean-jsdoc-theme-without-scrollbar.min.css +0 -0
- package/docs/styles/clean-jsdoc-theme.min.css +0 -0
- package/docs/text-to-array.js.html +0 -0
- package/docs/titleize.js.html +0 -0
- package/docs/without.js.html +0 -0
- package/index.js +119 -119
- package/package.json +48 -48
- package/src/arrange-array.js +25 -25
- package/src/create-class.js +35 -35
- package/src/current-loc.js +0 -0
- package/src/defaults-deep.js +20 -20
- package/src/delay.js +19 -19
- package/src/extract-text.js +23 -23
- package/src/fill-object.js +17 -17
- package/src/filter-duplicate.js +26 -26
- package/src/filter-index.js +17 -17
- package/src/format-text.js +88 -88
- package/src/generate-id.js +35 -35
- package/src/get-caller-filename.js +25 -25
- package/src/get-global-module-dir.js +24 -20
- package/src/get-index.js +15 -15
- package/src/get-key-by-value.js +12 -12
- package/src/includes.js +18 -18
- package/src/is-class.js +13 -13
- package/src/is-set.js +11 -11
- package/src/log.js +19 -19
- package/src/merge-objects-by-key.js +24 -24
- package/src/paginate.js +45 -45
- package/src/parse-args-argv.js +0 -0
- package/src/parse-duration.js +14 -14
- package/src/parse-env.js +0 -0
- package/src/parse-kv-string.js +21 -21
- package/src/parse-object.js +76 -76
- package/src/pascal-case.js +14 -14
- package/src/random-range.js +15 -15
- package/src/resolve-path.js +0 -0
- package/src/round.js +13 -13
- package/src/sec-to-hms.js +27 -27
- package/src/set-immediate.js +12 -12
- package/src/set-interval.js +56 -56
- package/src/set-timeout.js +34 -34
- package/src/shim.js +28 -28
- package/src/text-to-array.js +17 -17
- package/src/titleize.js +37 -37
- package/src/without.js +18 -18
- package/test/arrange-array.js +41 -41
- package/test/create-class.js +33 -33
- package/test/current-loc.js +24 -24
- package/test/defaults-deep.js +19 -19
- package/test/delay.js +17 -17
- package/test/extract-text.js +17 -17
- package/test/fill-object.js +17 -17
- package/test/filter-duplicate.js +19 -19
- package/test/filter-index.js +17 -17
- package/test/format-text.js +26 -26
- package/test/generate-id.js +28 -28
- package/test/get-caller-filename.js +22 -22
- package/test/get-global-module-dir.js +51 -51
- package/test/get-index.js +17 -17
- package/test/get-key-by-value.js +17 -17
- package/test/includes.js +18 -18
- package/test/is-class.js +19 -19
- package/test/is-set.js +21 -21
- package/test/log.js +47 -47
- package/test/merge-objects-by-key.js +19 -19
- package/test/paginate.js +24 -24
- package/test/parse-args-argv.js +63 -63
- package/test/parse-duration.js +18 -18
- package/test/parse-env.js +35 -35
- package/test/parse-kv-string.js +17 -17
- package/test/parse-object.js +30 -30
- package/test/pascal-case.js +18 -18
- package/test/random-range.js +21 -21
- package/test/resolve-path.js +22 -22
- package/test/round.js +19 -19
- package/test/sec-to-hms.js +18 -18
- package/test/set-immediate.js +17 -17
- package/test/set-interval.js +196 -196
- package/test/set-timeout.js +120 -120
- package/test/shim.js +34 -34
- package/test/text-to-array.js +18 -18
- package/test/titleize.js +27 -27
- package/test/without.js +17 -17
package/test/filter-duplicate.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
/* eslint-env mocha */
|
|
2
|
-
import { expect } from 'chai'
|
|
3
|
-
import fn from '../src/filter-duplicate.js'
|
|
4
|
-
|
|
5
|
-
describe('filterDuplicate', function () {
|
|
6
|
-
it('returns duplicated object entries', function () {
|
|
7
|
-
const rows = [{ n: 'a' }, { n: 'b' }, { n: 'a' }]
|
|
8
|
-
expect(fn(rows, 'n')).to.deep.equal([{ n: 'a' }, { n: 'a' }])
|
|
9
|
-
})
|
|
10
|
-
|
|
11
|
-
it('returns empty array when no duplication exists', function () {
|
|
12
|
-
expect(fn([{ n: 'a' }, { n: 'b' }], 'n')).to.deep.equal([])
|
|
13
|
-
})
|
|
14
|
-
|
|
15
|
-
it('returns all entries participating in duplicated keys', function () {
|
|
16
|
-
const rows = [{ n: 'a' }, { n: 'b' }, { n: 'a' }, { n: 'b' }]
|
|
17
|
-
expect(fn(rows, 'n')).to.deep.equal(rows)
|
|
18
|
-
})
|
|
19
|
-
})
|
|
1
|
+
/* eslint-env mocha */
|
|
2
|
+
import { expect } from 'chai'
|
|
3
|
+
import fn from '../src/filter-duplicate.js'
|
|
4
|
+
|
|
5
|
+
describe('filterDuplicate', function () {
|
|
6
|
+
it('returns duplicated object entries', function () {
|
|
7
|
+
const rows = [{ n: 'a' }, { n: 'b' }, { n: 'a' }]
|
|
8
|
+
expect(fn(rows, 'n')).to.deep.equal([{ n: 'a' }, { n: 'a' }])
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
it('returns empty array when no duplication exists', function () {
|
|
12
|
+
expect(fn([{ n: 'a' }, { n: 'b' }], 'n')).to.deep.equal([])
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
it('returns all entries participating in duplicated keys', function () {
|
|
16
|
+
const rows = [{ n: 'a' }, { n: 'b' }, { n: 'a' }, { n: 'b' }]
|
|
17
|
+
expect(fn(rows, 'n')).to.deep.equal(rows)
|
|
18
|
+
})
|
|
19
|
+
})
|
package/test/filter-index.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
/* eslint-env mocha */
|
|
2
|
-
import { expect } from 'chai'
|
|
3
|
-
import fn from '../src/filter-index.js'
|
|
4
|
-
|
|
5
|
-
describe('filterIndex', function () {
|
|
6
|
-
it('returns indexes matching predicate', function () {
|
|
7
|
-
expect(fn([1, 2, 3, 4], n => n % 2 === 0)).to.deep.equal([1, 3])
|
|
8
|
-
})
|
|
9
|
-
|
|
10
|
-
it('returns empty array when no items match', function () {
|
|
11
|
-
expect(fn([1, 3, 5], n => n % 2 === 0)).to.deep.equal([])
|
|
12
|
-
})
|
|
13
|
-
|
|
14
|
-
it('returns all indexes when all items match', function () {
|
|
15
|
-
expect(fn([2, 4], n => n % 2 === 0)).to.deep.equal([0, 1])
|
|
16
|
-
})
|
|
17
|
-
})
|
|
1
|
+
/* eslint-env mocha */
|
|
2
|
+
import { expect } from 'chai'
|
|
3
|
+
import fn from '../src/filter-index.js'
|
|
4
|
+
|
|
5
|
+
describe('filterIndex', function () {
|
|
6
|
+
it('returns indexes matching predicate', function () {
|
|
7
|
+
expect(fn([1, 2, 3, 4], n => n % 2 === 0)).to.deep.equal([1, 3])
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
it('returns empty array when no items match', function () {
|
|
11
|
+
expect(fn([1, 3, 5], n => n % 2 === 0)).to.deep.equal([])
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
it('returns all indexes when all items match', function () {
|
|
15
|
+
expect(fn([2, 4], n => n % 2 === 0)).to.deep.equal([0, 1])
|
|
16
|
+
})
|
|
17
|
+
})
|
package/test/format-text.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
/* eslint-env mocha */
|
|
2
|
-
import { expect } from 'chai'
|
|
3
|
-
import fn from '../src/format-text.js'
|
|
4
|
-
|
|
5
|
-
describe('formatText', function () {
|
|
6
|
-
it('applies sprintf and modifiers', function () {
|
|
7
|
-
expect(fn('hello %s', 'world')).to.equal('hello world')
|
|
8
|
-
expect(fn('Collected %s|toLower|upperFirst', 'iTeMs')).to.equal('Collected Items')
|
|
9
|
-
})
|
|
10
|
-
|
|
11
|
-
it('works as plain sprintf when no modifiers are present', function () {
|
|
12
|
-
expect(fn('Total: %d', 10)).to.equal('Total: 10')
|
|
13
|
-
})
|
|
14
|
-
|
|
15
|
-
it('keeps escaped percent literals', function () {
|
|
16
|
-
expect(fn('Progress %% %d', 50)).to.equal('Progress % 50')
|
|
17
|
-
})
|
|
18
|
-
|
|
19
|
-
it('supports multiple modifiers in sequence', function () {
|
|
20
|
-
expect(fn('Name: %s|trim|pascalCase', ' hello world ')).to.equal('Name: HelloWorld')
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
it('supports secToHms modifier for duration values', function () {
|
|
24
|
-
expect(fn('Elapsed %s|secToHms', 61)).to.equal('Elapsed 01:01')
|
|
25
|
-
})
|
|
26
|
-
})
|
|
1
|
+
/* eslint-env mocha */
|
|
2
|
+
import { expect } from 'chai'
|
|
3
|
+
import fn from '../src/format-text.js'
|
|
4
|
+
|
|
5
|
+
describe('formatText', function () {
|
|
6
|
+
it('applies sprintf and modifiers', function () {
|
|
7
|
+
expect(fn('hello %s', 'world')).to.equal('hello world')
|
|
8
|
+
expect(fn('Collected %s|toLower|upperFirst', 'iTeMs')).to.equal('Collected Items')
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
it('works as plain sprintf when no modifiers are present', function () {
|
|
12
|
+
expect(fn('Total: %d', 10)).to.equal('Total: 10')
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
it('keeps escaped percent literals', function () {
|
|
16
|
+
expect(fn('Progress %% %d', 50)).to.equal('Progress % 50')
|
|
17
|
+
})
|
|
18
|
+
|
|
19
|
+
it('supports multiple modifiers in sequence', function () {
|
|
20
|
+
expect(fn('Name: %s|trim|pascalCase', ' hello world ')).to.equal('Name: HelloWorld')
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
it('supports secToHms modifier for duration values', function () {
|
|
24
|
+
expect(fn('Elapsed %s|secToHms', 61)).to.equal('Elapsed 01:01')
|
|
25
|
+
})
|
|
26
|
+
})
|
package/test/generate-id.js
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
/* eslint-env mocha */
|
|
2
|
-
import { expect } from 'chai'
|
|
3
|
-
import fn from '../src/generate-id.js'
|
|
4
|
-
|
|
5
|
-
describe('generateId', function () {
|
|
6
|
-
it('generates ids based on options', function () {
|
|
7
|
-
const id = fn()
|
|
8
|
-
expect(id).to.be.a('string')
|
|
9
|
-
expect(id).to.have.lengthOf(13)
|
|
10
|
-
|
|
11
|
-
const alpha = fn('alpha')
|
|
12
|
-
expect(alpha).to.match(/^[a-zA-Z]+$/)
|
|
13
|
-
|
|
14
|
-
const intVal = fn('int')
|
|
15
|
-
expect(intVal).to.be.a('number')
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
it('supports lower and upper case options', function () {
|
|
19
|
-
expect(fn({ case: 'lower' })).to.match(/^[a-z0-9]+$/)
|
|
20
|
-
expect(fn({ case: 'upper' })).to.match(/^[A-Z0-9]+$/)
|
|
21
|
-
})
|
|
22
|
-
|
|
23
|
-
it('returns generator instance when requested', function () {
|
|
24
|
-
const inst = fn({ returnInstance: true })
|
|
25
|
-
expect(inst).to.be.a('function')
|
|
26
|
-
expect(inst()).to.be.a('string')
|
|
27
|
-
})
|
|
28
|
-
})
|
|
1
|
+
/* eslint-env mocha */
|
|
2
|
+
import { expect } from 'chai'
|
|
3
|
+
import fn from '../src/generate-id.js'
|
|
4
|
+
|
|
5
|
+
describe('generateId', function () {
|
|
6
|
+
it('generates ids based on options', function () {
|
|
7
|
+
const id = fn()
|
|
8
|
+
expect(id).to.be.a('string')
|
|
9
|
+
expect(id).to.have.lengthOf(13)
|
|
10
|
+
|
|
11
|
+
const alpha = fn('alpha')
|
|
12
|
+
expect(alpha).to.match(/^[a-zA-Z]+$/)
|
|
13
|
+
|
|
14
|
+
const intVal = fn('int')
|
|
15
|
+
expect(intVal).to.be.a('number')
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
it('supports lower and upper case options', function () {
|
|
19
|
+
expect(fn({ case: 'lower' })).to.match(/^[a-z0-9]+$/)
|
|
20
|
+
expect(fn({ case: 'upper' })).to.match(/^[A-Z0-9]+$/)
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
it('returns generator instance when requested', function () {
|
|
24
|
+
const inst = fn({ returnInstance: true })
|
|
25
|
+
expect(inst).to.be.a('function')
|
|
26
|
+
expect(inst()).to.be.a('string')
|
|
27
|
+
})
|
|
28
|
+
})
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
/* eslint-env mocha */
|
|
2
|
-
import { expect } from 'chai'
|
|
3
|
-
import fn from '../src/get-caller-filename.js'
|
|
4
|
-
|
|
5
|
-
describe('getCallerFilename', function () {
|
|
6
|
-
it('returns caller path', function () {
|
|
7
|
-
const got = fn()
|
|
8
|
-
expect(got).to.be.a('string')
|
|
9
|
-
expect(got).to.include('/test/get-caller-filename.js')
|
|
10
|
-
})
|
|
11
|
-
|
|
12
|
-
it('returns a stable value on repeated calls', function () {
|
|
13
|
-
const a = fn()
|
|
14
|
-
const b = fn()
|
|
15
|
-
expect(a).to.equal(b)
|
|
16
|
-
})
|
|
17
|
-
|
|
18
|
-
it('returns a path ending with js extension', function () {
|
|
19
|
-
const got = fn()
|
|
20
|
-
expect(got.endsWith('.js')).to.equal(true)
|
|
21
|
-
})
|
|
22
|
-
})
|
|
1
|
+
/* eslint-env mocha */
|
|
2
|
+
import { expect } from 'chai'
|
|
3
|
+
import fn from '../src/get-caller-filename.js'
|
|
4
|
+
|
|
5
|
+
describe('getCallerFilename', function () {
|
|
6
|
+
it('returns caller path', function () {
|
|
7
|
+
const got = fn()
|
|
8
|
+
expect(got).to.be.a('string')
|
|
9
|
+
expect(got).to.include('/test/get-caller-filename.js')
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
it('returns a stable value on repeated calls', function () {
|
|
13
|
+
const a = fn()
|
|
14
|
+
const b = fn()
|
|
15
|
+
expect(a).to.equal(b)
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
it('returns a path ending with js extension', function () {
|
|
19
|
+
const got = fn()
|
|
20
|
+
expect(got.endsWith('.js')).to.equal(true)
|
|
21
|
+
})
|
|
22
|
+
})
|
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
/* eslint-env mocha */
|
|
2
|
-
import { expect } from 'chai'
|
|
3
|
-
import path from 'path'
|
|
4
|
-
import fn from '../src/get-global-module-dir.js'
|
|
5
|
-
|
|
6
|
-
const originalPlatformDesc = Object.getOwnPropertyDescriptor(process, 'platform')
|
|
7
|
-
const originalExecPathDesc = Object.getOwnPropertyDescriptor(process, 'execPath')
|
|
8
|
-
const originalAppData = process.env.APPDATA
|
|
9
|
-
|
|
10
|
-
function setProcessProp (name, value) {
|
|
11
|
-
Object.defineProperty(process, name, {
|
|
12
|
-
value,
|
|
13
|
-
configurable: true
|
|
14
|
-
})
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
describe('getGlobalModuleDir', function () {
|
|
18
|
-
afterEach(function () {
|
|
19
|
-
if (originalPlatformDesc) Object.defineProperty(process, 'platform', originalPlatformDesc)
|
|
20
|
-
if (originalExecPathDesc) Object.defineProperty(process, 'execPath', originalExecPathDesc)
|
|
21
|
-
|
|
22
|
-
if (originalAppData === undefined) delete process.env.APPDATA
|
|
23
|
-
else process.env.APPDATA = originalAppData
|
|
24
|
-
})
|
|
25
|
-
|
|
26
|
-
it('returns lib/node_modules for non-win32 platforms', function () {
|
|
27
|
-
setProcessProp('platform', 'linux')
|
|
28
|
-
setProcessProp('execPath', '/opt/node/bin/node')
|
|
29
|
-
|
|
30
|
-
const result = fn()
|
|
31
|
-
expect(result).to.equal(path.resolve('/opt/node/lib/node_modules'))
|
|
32
|
-
})
|
|
33
|
-
|
|
34
|
-
it('uses APPDATA on win32 when provided', function () {
|
|
35
|
-
setProcessProp('platform', 'win32')
|
|
36
|
-
setProcessProp('execPath', '/Program Files/nodejs/node.exe')
|
|
37
|
-
process.env.APPDATA = '/Users/test/AppData/Roaming'
|
|
38
|
-
|
|
39
|
-
const result = fn()
|
|
40
|
-
expect(result).to.equal(path.resolve('/Users/test/AppData/Roaming/npm/node_modules'))
|
|
41
|
-
})
|
|
42
|
-
|
|
43
|
-
it('falls back to exec directory on win32 when APPDATA is missing', function () {
|
|
44
|
-
setProcessProp('platform', 'win32')
|
|
45
|
-
setProcessProp('execPath', '/Program Files/nodejs/node.exe')
|
|
46
|
-
delete process.env.APPDATA
|
|
47
|
-
|
|
48
|
-
const result = fn()
|
|
49
|
-
expect(result).to.equal(path.resolve('/Program Files/nodejs/node_modules'))
|
|
50
|
-
})
|
|
51
|
-
})
|
|
1
|
+
/* eslint-env mocha */
|
|
2
|
+
import { expect } from 'chai'
|
|
3
|
+
import path from 'path'
|
|
4
|
+
import fn from '../src/get-global-module-dir.js'
|
|
5
|
+
|
|
6
|
+
const originalPlatformDesc = Object.getOwnPropertyDescriptor(process, 'platform')
|
|
7
|
+
const originalExecPathDesc = Object.getOwnPropertyDescriptor(process, 'execPath')
|
|
8
|
+
const originalAppData = process.env.APPDATA
|
|
9
|
+
|
|
10
|
+
function setProcessProp (name, value) {
|
|
11
|
+
Object.defineProperty(process, name, {
|
|
12
|
+
value,
|
|
13
|
+
configurable: true
|
|
14
|
+
})
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
describe('getGlobalModuleDir', function () {
|
|
18
|
+
afterEach(function () {
|
|
19
|
+
if (originalPlatformDesc) Object.defineProperty(process, 'platform', originalPlatformDesc)
|
|
20
|
+
if (originalExecPathDesc) Object.defineProperty(process, 'execPath', originalExecPathDesc)
|
|
21
|
+
|
|
22
|
+
if (originalAppData === undefined) delete process.env.APPDATA
|
|
23
|
+
else process.env.APPDATA = originalAppData
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
it('returns lib/node_modules for non-win32 platforms', function () {
|
|
27
|
+
setProcessProp('platform', 'linux')
|
|
28
|
+
setProcessProp('execPath', '/opt/node/bin/node')
|
|
29
|
+
|
|
30
|
+
const result = fn()
|
|
31
|
+
expect(result).to.equal(path.resolve('/opt/node/lib/node_modules'))
|
|
32
|
+
})
|
|
33
|
+
|
|
34
|
+
it('uses APPDATA on win32 when provided', function () {
|
|
35
|
+
setProcessProp('platform', 'win32')
|
|
36
|
+
setProcessProp('execPath', '/Program Files/nodejs/node.exe')
|
|
37
|
+
process.env.APPDATA = '/Users/test/AppData/Roaming'
|
|
38
|
+
|
|
39
|
+
const result = fn()
|
|
40
|
+
expect(result).to.equal(path.resolve('/Users/test/AppData/Roaming/npm/node_modules'))
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
it('falls back to exec directory on win32 when APPDATA is missing', function () {
|
|
44
|
+
setProcessProp('platform', 'win32')
|
|
45
|
+
setProcessProp('execPath', '/Program Files/nodejs/node.exe')
|
|
46
|
+
delete process.env.APPDATA
|
|
47
|
+
|
|
48
|
+
const result = fn()
|
|
49
|
+
expect(result).to.equal(path.resolve('/Program Files/nodejs/node_modules'))
|
|
50
|
+
})
|
|
51
|
+
})
|
package/test/get-index.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
/* eslint-env mocha */
|
|
2
|
-
import { expect } from 'chai'
|
|
3
|
-
import fn from '../src/get-index.js'
|
|
4
|
-
|
|
5
|
-
describe('getIndex', function () {
|
|
6
|
-
it('returns indexes of matching values', function () {
|
|
7
|
-
expect(fn([1, 2, 3, 4], n => n > 2)).to.deep.equal([2, 3])
|
|
8
|
-
})
|
|
9
|
-
|
|
10
|
-
it('returns empty array for empty input', function () {
|
|
11
|
-
expect(fn([], () => true)).to.deep.equal([])
|
|
12
|
-
})
|
|
13
|
-
|
|
14
|
-
it('returns all indexes when matcher always true', function () {
|
|
15
|
-
expect(fn(['a', 'b'], () => true)).to.deep.equal([0, 1])
|
|
16
|
-
})
|
|
17
|
-
})
|
|
1
|
+
/* eslint-env mocha */
|
|
2
|
+
import { expect } from 'chai'
|
|
3
|
+
import fn from '../src/get-index.js'
|
|
4
|
+
|
|
5
|
+
describe('getIndex', function () {
|
|
6
|
+
it('returns indexes of matching values', function () {
|
|
7
|
+
expect(fn([1, 2, 3, 4], n => n > 2)).to.deep.equal([2, 3])
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
it('returns empty array for empty input', function () {
|
|
11
|
+
expect(fn([], () => true)).to.deep.equal([])
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
it('returns all indexes when matcher always true', function () {
|
|
15
|
+
expect(fn(['a', 'b'], () => true)).to.deep.equal([0, 1])
|
|
16
|
+
})
|
|
17
|
+
})
|
package/test/get-key-by-value.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
/* eslint-env mocha */
|
|
2
|
-
import { expect } from 'chai'
|
|
3
|
-
import fn from '../src/get-key-by-value.js'
|
|
4
|
-
|
|
5
|
-
describe('getKeyByValue', function () {
|
|
6
|
-
it('returns key by matching value', function () {
|
|
7
|
-
expect(fn({ a: 1, b: 2 }, 2)).to.equal('b')
|
|
8
|
-
})
|
|
9
|
-
|
|
10
|
-
it('returns undefined when no value is found', function () {
|
|
11
|
-
expect(fn({ a: 1 }, 9)).to.equal(undefined)
|
|
12
|
-
})
|
|
13
|
-
|
|
14
|
-
it('returns first matching key when values are duplicated', function () {
|
|
15
|
-
expect(fn({ a: 1, b: 1 }, 1)).to.equal('a')
|
|
16
|
-
})
|
|
17
|
-
})
|
|
1
|
+
/* eslint-env mocha */
|
|
2
|
+
import { expect } from 'chai'
|
|
3
|
+
import fn from '../src/get-key-by-value.js'
|
|
4
|
+
|
|
5
|
+
describe('getKeyByValue', function () {
|
|
6
|
+
it('returns key by matching value', function () {
|
|
7
|
+
expect(fn({ a: 1, b: 2 }, 2)).to.equal('b')
|
|
8
|
+
})
|
|
9
|
+
|
|
10
|
+
it('returns undefined when no value is found', function () {
|
|
11
|
+
expect(fn({ a: 1 }, 9)).to.equal(undefined)
|
|
12
|
+
})
|
|
13
|
+
|
|
14
|
+
it('returns first matching key when values are duplicated', function () {
|
|
15
|
+
expect(fn({ a: 1, b: 1 }, 1)).to.equal('a')
|
|
16
|
+
})
|
|
17
|
+
})
|
package/test/includes.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
/* eslint-env mocha */
|
|
2
|
-
import { expect } from 'chai'
|
|
3
|
-
import fn from '../src/includes.js'
|
|
4
|
-
|
|
5
|
-
describe('includes', function () {
|
|
6
|
-
it('checks if any matcher exists in array', function () {
|
|
7
|
-
expect(fn('b', ['a', 'b'])).to.equal(true)
|
|
8
|
-
expect(fn(['x', 'y'], ['a', 'b'])).to.equal(false)
|
|
9
|
-
})
|
|
10
|
-
|
|
11
|
-
it('supports matcher arrays with at least one hit', function () {
|
|
12
|
-
expect(fn(['x', 'b'], ['a', 'b'])).to.equal(true)
|
|
13
|
-
})
|
|
14
|
-
|
|
15
|
-
it('returns false for empty matcher and array', function () {
|
|
16
|
-
expect(fn([], [])).to.equal(false)
|
|
17
|
-
})
|
|
18
|
-
})
|
|
1
|
+
/* eslint-env mocha */
|
|
2
|
+
import { expect } from 'chai'
|
|
3
|
+
import fn from '../src/includes.js'
|
|
4
|
+
|
|
5
|
+
describe('includes', function () {
|
|
6
|
+
it('checks if any matcher exists in array', function () {
|
|
7
|
+
expect(fn('b', ['a', 'b'])).to.equal(true)
|
|
8
|
+
expect(fn(['x', 'y'], ['a', 'b'])).to.equal(false)
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
it('supports matcher arrays with at least one hit', function () {
|
|
12
|
+
expect(fn(['x', 'b'], ['a', 'b'])).to.equal(true)
|
|
13
|
+
})
|
|
14
|
+
|
|
15
|
+
it('returns false for empty matcher and array', function () {
|
|
16
|
+
expect(fn([], [])).to.equal(false)
|
|
17
|
+
})
|
|
18
|
+
})
|
package/test/is-class.js
CHANGED
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
/* eslint-env mocha */
|
|
2
|
-
import { expect } from 'chai'
|
|
3
|
-
import fn from '../src/is-class.js'
|
|
4
|
-
|
|
5
|
-
describe('isClass', function () {
|
|
6
|
-
it('identifies class constructors', function () {
|
|
7
|
-
class C {}
|
|
8
|
-
expect(fn(C)).to.equal(true)
|
|
9
|
-
expect(fn(() => {})).to.equal(false)
|
|
10
|
-
})
|
|
11
|
-
|
|
12
|
-
it('returns false for plain objects', function () {
|
|
13
|
-
expect(fn({})).to.equal(false)
|
|
14
|
-
})
|
|
15
|
-
|
|
16
|
-
it('returns false for null values', function () {
|
|
17
|
-
expect(fn(null)).to.equal(false)
|
|
18
|
-
})
|
|
19
|
-
})
|
|
1
|
+
/* eslint-env mocha */
|
|
2
|
+
import { expect } from 'chai'
|
|
3
|
+
import fn from '../src/is-class.js'
|
|
4
|
+
|
|
5
|
+
describe('isClass', function () {
|
|
6
|
+
it('identifies class constructors', function () {
|
|
7
|
+
class C {}
|
|
8
|
+
expect(fn(C)).to.equal(true)
|
|
9
|
+
expect(fn(() => {})).to.equal(false)
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
it('returns false for plain objects', function () {
|
|
13
|
+
expect(fn({})).to.equal(false)
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
it('returns false for null values', function () {
|
|
17
|
+
expect(fn(null)).to.equal(false)
|
|
18
|
+
})
|
|
19
|
+
})
|
package/test/is-set.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
/* eslint-env mocha */
|
|
2
|
-
import { expect } from 'chai'
|
|
3
|
-
import fn from '../src/is-set.js'
|
|
4
|
-
|
|
5
|
-
describe('isSet', function () {
|
|
6
|
-
it('returns true for non-null and non-undefined values', function () {
|
|
7
|
-
expect(fn(0)).to.equal(true)
|
|
8
|
-
expect(fn(null)).to.equal(false)
|
|
9
|
-
expect(fn(undefined)).to.equal(false)
|
|
10
|
-
})
|
|
11
|
-
|
|
12
|
-
it('returns true for empty strings and false booleans', function () {
|
|
13
|
-
expect(fn('')).to.equal(true)
|
|
14
|
-
expect(fn(false)).to.equal(true)
|
|
15
|
-
})
|
|
16
|
-
|
|
17
|
-
it('returns true for empty arrays and objects', function () {
|
|
18
|
-
expect(fn([])).to.equal(true)
|
|
19
|
-
expect(fn({})).to.equal(true)
|
|
20
|
-
})
|
|
21
|
-
})
|
|
1
|
+
/* eslint-env mocha */
|
|
2
|
+
import { expect } from 'chai'
|
|
3
|
+
import fn from '../src/is-set.js'
|
|
4
|
+
|
|
5
|
+
describe('isSet', function () {
|
|
6
|
+
it('returns true for non-null and non-undefined values', function () {
|
|
7
|
+
expect(fn(0)).to.equal(true)
|
|
8
|
+
expect(fn(null)).to.equal(false)
|
|
9
|
+
expect(fn(undefined)).to.equal(false)
|
|
10
|
+
})
|
|
11
|
+
|
|
12
|
+
it('returns true for empty strings and false booleans', function () {
|
|
13
|
+
expect(fn('')).to.equal(true)
|
|
14
|
+
expect(fn(false)).to.equal(true)
|
|
15
|
+
})
|
|
16
|
+
|
|
17
|
+
it('returns true for empty arrays and objects', function () {
|
|
18
|
+
expect(fn([])).to.equal(true)
|
|
19
|
+
expect(fn({})).to.equal(true)
|
|
20
|
+
})
|
|
21
|
+
})
|
package/test/log.js
CHANGED
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
/* eslint-env mocha */
|
|
2
|
-
import { expect } from 'chai'
|
|
3
|
-
import { log, logError } from '../src/log.js'
|
|
4
|
-
|
|
5
|
-
describe('log', function () {
|
|
6
|
-
it('calls console log and console error', function () {
|
|
7
|
-
const originalLog = console.log
|
|
8
|
-
const originalError = console.error
|
|
9
|
-
const logs = []
|
|
10
|
-
const errors = []
|
|
11
|
-
console.log = (...args) => logs.push(args)
|
|
12
|
-
console.error = (...args) => errors.push(args)
|
|
13
|
-
try {
|
|
14
|
-
log('Hello %s', 'world')
|
|
15
|
-
logError('Oops %s', 'x')
|
|
16
|
-
expect(logs.length).to.equal(1)
|
|
17
|
-
expect(errors.length).to.equal(1)
|
|
18
|
-
} finally {
|
|
19
|
-
console.log = originalLog
|
|
20
|
-
console.error = originalError
|
|
21
|
-
}
|
|
22
|
-
})
|
|
23
|
-
|
|
24
|
-
it('passes non-string items directly to console.log', function () {
|
|
25
|
-
const originalLog = console.log
|
|
26
|
-
const logs = []
|
|
27
|
-
console.log = (...args) => logs.push(args)
|
|
28
|
-
try {
|
|
29
|
-
log({ a: 1 })
|
|
30
|
-
expect(logs[0][0]).to.deep.equal({ a: 1 })
|
|
31
|
-
} finally {
|
|
32
|
-
console.log = originalLog
|
|
33
|
-
}
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
it('formats string labels with timestamp prefix', function () {
|
|
37
|
-
const originalLog = console.log
|
|
38
|
-
const logs = []
|
|
39
|
-
console.log = (...args) => logs.push(args)
|
|
40
|
-
try {
|
|
41
|
-
log('Value %d', 7)
|
|
42
|
-
expect(logs[0][0]).to.match(/^\[[^\]]+\] Value 7$/)
|
|
43
|
-
} finally {
|
|
44
|
-
console.log = originalLog
|
|
45
|
-
}
|
|
46
|
-
})
|
|
47
|
-
})
|
|
1
|
+
/* eslint-env mocha */
|
|
2
|
+
import { expect } from 'chai'
|
|
3
|
+
import { log, logError } from '../src/log.js'
|
|
4
|
+
|
|
5
|
+
describe('log', function () {
|
|
6
|
+
it('calls console log and console error', function () {
|
|
7
|
+
const originalLog = console.log
|
|
8
|
+
const originalError = console.error
|
|
9
|
+
const logs = []
|
|
10
|
+
const errors = []
|
|
11
|
+
console.log = (...args) => logs.push(args)
|
|
12
|
+
console.error = (...args) => errors.push(args)
|
|
13
|
+
try {
|
|
14
|
+
log('Hello %s', 'world')
|
|
15
|
+
logError('Oops %s', 'x')
|
|
16
|
+
expect(logs.length).to.equal(1)
|
|
17
|
+
expect(errors.length).to.equal(1)
|
|
18
|
+
} finally {
|
|
19
|
+
console.log = originalLog
|
|
20
|
+
console.error = originalError
|
|
21
|
+
}
|
|
22
|
+
})
|
|
23
|
+
|
|
24
|
+
it('passes non-string items directly to console.log', function () {
|
|
25
|
+
const originalLog = console.log
|
|
26
|
+
const logs = []
|
|
27
|
+
console.log = (...args) => logs.push(args)
|
|
28
|
+
try {
|
|
29
|
+
log({ a: 1 })
|
|
30
|
+
expect(logs[0][0]).to.deep.equal({ a: 1 })
|
|
31
|
+
} finally {
|
|
32
|
+
console.log = originalLog
|
|
33
|
+
}
|
|
34
|
+
})
|
|
35
|
+
|
|
36
|
+
it('formats string labels with timestamp prefix', function () {
|
|
37
|
+
const originalLog = console.log
|
|
38
|
+
const logs = []
|
|
39
|
+
console.log = (...args) => logs.push(args)
|
|
40
|
+
try {
|
|
41
|
+
log('Value %d', 7)
|
|
42
|
+
expect(logs[0][0]).to.match(/^\[[^\]]+\] Value 7$/)
|
|
43
|
+
} finally {
|
|
44
|
+
console.log = originalLog
|
|
45
|
+
}
|
|
46
|
+
})
|
|
47
|
+
})
|