aneka 0.10.0 → 0.11.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/CHANGES.md +4 -0
- package/package.json +1 -1
- package/src/merge-objects-by-key.js +1 -1
- package/src/parse-args-argv.js +5 -4
- package/src/random-range.js +1 -1
- package/test/filter-duplicate.js +7 -7
- package/test/filter-index.js +7 -8
- package/test/merge-objects-by-key.js +1 -1
- package/test/parse-kv-string.js +1 -1
package/CHANGES.md
CHANGED
package/package.json
CHANGED
package/src/parse-args-argv.js
CHANGED
|
@@ -25,8 +25,8 @@ async function parseWithParser () {
|
|
|
25
25
|
})
|
|
26
26
|
}
|
|
27
27
|
|
|
28
|
-
async function parseWithYargs () {
|
|
29
|
-
const pkgFile = `${process.cwd()}/package.json`
|
|
28
|
+
async function parseWithYargs (cwd) {
|
|
29
|
+
const pkgFile = `${cwd ?? process.cwd()}/package.json`
|
|
30
30
|
const pkg = JSON.parse(fs.readFileSync(pkgFile, 'utf8'))
|
|
31
31
|
let name = `node ${pkg.main}`
|
|
32
32
|
if (pkg.bin) name = path.basename(pkg.bin, '.js')
|
|
@@ -52,13 +52,14 @@ async function parseWithYargs () {
|
|
|
52
52
|
* @async
|
|
53
53
|
* @param {function(Object): Object} [sanitizer] - If provided, result will be sanitized with this function
|
|
54
54
|
* @param {boolean} [useParser] - If ```true```, skip {@link https://github.com/yargs/yargs|yargs}
|
|
55
|
+
* @param {string} [cwd] - If provided, current working directory is set to this
|
|
55
56
|
* @returns {{args: Array, argv: Object}} An object containing ```args``` and ```argv```
|
|
56
57
|
* @see App#args
|
|
57
58
|
* @see App#argv
|
|
58
59
|
*/
|
|
59
|
-
async function parseArgsArgv (sanitizer, useParser) {
|
|
60
|
+
async function parseArgsArgv (sanitizer, useParser, cwd) {
|
|
60
61
|
if (!useParser) useParser = find(process.argv, a => a.startsWith('--spawn'))
|
|
61
|
-
let argv = useParser ? await parseWithParser
|
|
62
|
+
let argv = useParser ? await parseWithParser() : await parseWithYargs(cwd)
|
|
62
63
|
const args = argv._
|
|
63
64
|
delete argv._
|
|
64
65
|
delete argv.$0
|
package/src/random-range.js
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* @param {boolean} alpha - Set ```true``` to return alphanumeric characters
|
|
7
7
|
* @returns
|
|
8
8
|
*/
|
|
9
|
-
function randomRange(min = 0, max = 65439, alpha = false) {
|
|
9
|
+
function randomRange (min = 0, max = 65439, alpha = false) {
|
|
10
10
|
const num = Math.floor(Math.random() * (max - min + 1) + min)
|
|
11
11
|
if (!alpha) return num
|
|
12
12
|
return String.fromCharCode(96 + num)
|
package/test/filter-duplicate.js
CHANGED
|
@@ -4,9 +4,9 @@ import fn from '../src/filter-duplicate.js'
|
|
|
4
4
|
describe('filterDuplicate', function () {
|
|
5
5
|
it('No duplication', function () {
|
|
6
6
|
const items = [
|
|
7
|
-
{ id: 1, name:
|
|
8
|
-
{ id: 2, name:
|
|
9
|
-
{ id: 3, name:
|
|
7
|
+
{ id: 1, name: 'one' },
|
|
8
|
+
{ id: 2, name: 'two' },
|
|
9
|
+
{ id: 3, name: 'three' }
|
|
10
10
|
]
|
|
11
11
|
const dups = fn(items, 'name')
|
|
12
12
|
expect(dups).to.have.lengthOf(0)
|
|
@@ -14,11 +14,11 @@ describe('filterDuplicate', function () {
|
|
|
14
14
|
|
|
15
15
|
it('Two duplications', function () {
|
|
16
16
|
const items = [
|
|
17
|
-
{ id: 1, name:
|
|
18
|
-
{ id: 2, name:
|
|
19
|
-
{ id: 3, name:
|
|
17
|
+
{ id: 1, name: 'one' },
|
|
18
|
+
{ id: 2, name: 'one' },
|
|
19
|
+
{ id: 3, name: 'three' }
|
|
20
20
|
]
|
|
21
21
|
const dups = fn(items, 'name')
|
|
22
22
|
expect(dups).to.have.lengthOf(2)
|
|
23
23
|
})
|
|
24
|
-
})
|
|
24
|
+
})
|
package/test/filter-index.js
CHANGED
|
@@ -4,9 +4,9 @@ import fn from '../src/filter-index.js'
|
|
|
4
4
|
describe('filterIndex', function () {
|
|
5
5
|
it('Nothing found', function () {
|
|
6
6
|
const items = [
|
|
7
|
-
{ id: 1, name:
|
|
8
|
-
{ id: 2, name:
|
|
9
|
-
{ id: 3, name:
|
|
7
|
+
{ id: 1, name: 'one' },
|
|
8
|
+
{ id: 2, name: 'two' },
|
|
9
|
+
{ id: 3, name: 'three' }
|
|
10
10
|
]
|
|
11
11
|
const dups = fn(items, item => item.name === 'zero')
|
|
12
12
|
expect(dups).to.have.lengthOf(0)
|
|
@@ -14,12 +14,11 @@ describe('filterIndex', function () {
|
|
|
14
14
|
|
|
15
15
|
it('Found 2 items', function () {
|
|
16
16
|
const items = [
|
|
17
|
-
{ id: 1, name:
|
|
18
|
-
{ id: 2, name:
|
|
19
|
-
{ id: 3, name:
|
|
17
|
+
{ id: 1, name: 'one' },
|
|
18
|
+
{ id: 2, name: 'two' },
|
|
19
|
+
{ id: 3, name: 'three' }
|
|
20
20
|
]
|
|
21
21
|
const dups = fn(items, item => ['one', 'two'].includes(item.name))
|
|
22
22
|
expect(dups).to.eql([0, 1])
|
|
23
23
|
})
|
|
24
|
-
|
|
25
|
-
})
|
|
24
|
+
})
|
package/test/parse-kv-string.js
CHANGED