mirror of
https://github.com/coderaiser/cloudcmd.git
synced 2026-01-23 02:35:49 +00:00
feature(package) add for-each-key from npm
This commit is contained in:
parent
f694857e63
commit
11c249c8f0
5 changed files with 4 additions and 64 deletions
|
|
@ -210,7 +210,7 @@ function readConfig(name) {
|
|||
const fs = require('fs');
|
||||
const tryCatch = require('try-catch');
|
||||
const jju = require('jju');
|
||||
const forEachKey = require('../common/for-each-key');
|
||||
const forEachKey = require('for-each-key');
|
||||
|
||||
const readjsonSync = (name) => jju.parse(fs.readFileSync(name, 'utf8'), {
|
||||
mode: 'json'
|
||||
|
|
@ -228,7 +228,7 @@ function readConfig(name) {
|
|||
|
||||
function help() {
|
||||
const bin = require('../json/help');
|
||||
const forEachKey = require('../common/for-each-key');
|
||||
const forEachKey = require('for-each-key');
|
||||
const currify = require('currify/legacy');
|
||||
const usage = 'Usage: cloudcmd [options]';
|
||||
const url = Info.homepage;
|
||||
|
|
@ -236,7 +236,6 @@ function help() {
|
|||
|
||||
console.log(usage);
|
||||
console.log('Options:');
|
||||
|
||||
forEachKey(log(' %s %s'), bin);
|
||||
console.log('\nGeneral help using Cloud Commander: <%s>', url);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ const {
|
|||
Dialog,
|
||||
} = DOM;
|
||||
|
||||
const forEachKey = require('../../../common/for-each-key');
|
||||
const forEachKey = require('for-each-key/legacy');
|
||||
const {
|
||||
TITLE,
|
||||
} = CloudCmd;
|
||||
|
|
|
|||
|
|
@ -1,11 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
const currify = require('currify/legacy');
|
||||
const setValue = currify((fn, obj, key) => fn(key, obj[key]));
|
||||
|
||||
module.exports = (fn, obj) => {
|
||||
Object
|
||||
.keys(obj)
|
||||
.forEach(setValue(fn, obj));
|
||||
};
|
||||
|
||||
|
|
@ -127,6 +127,7 @@
|
|||
"express": "^4.13.0",
|
||||
"files-io": "^1.2.0",
|
||||
"flop": "^4.0.0",
|
||||
"for-each-key": "^1.0.0",
|
||||
"format-io": "^0.9.6",
|
||||
"fullstore": "^1.0.0",
|
||||
"http-auth": "^3.2.3",
|
||||
|
|
|
|||
|
|
@ -1,49 +0,0 @@
|
|||
'use strict';
|
||||
|
||||
const test = require('tape');
|
||||
const diff = require('sinon-called-with-diff');
|
||||
const sinon = diff(require('sinon'));
|
||||
|
||||
const forEachKey = require('../../common/for-each-key');
|
||||
|
||||
test('forEachKey: on property', (t) => {
|
||||
const obj = {
|
||||
a: 'hello',
|
||||
};
|
||||
|
||||
const fn = sinon.stub();
|
||||
|
||||
forEachKey(fn, obj);
|
||||
|
||||
t.ok(fn.calledWith('a', 'hello'), 'should call fn');
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('forEachKey: a couple properties', (t) => {
|
||||
const obj = {
|
||||
a: 'hello',
|
||||
b: 'world',
|
||||
};
|
||||
|
||||
const fn = sinon.stub();
|
||||
|
||||
forEachKey(fn, obj);
|
||||
|
||||
t.ok(fn.calledWith('b', 'world'), 'should call fn');
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('forEachKey: count', (t) => {
|
||||
const obj = {
|
||||
a: 'hello',
|
||||
b: 'world',
|
||||
c: 'some',
|
||||
};
|
||||
|
||||
const fn = sinon.stub();
|
||||
|
||||
forEachKey(fn, obj);
|
||||
|
||||
t.equal(fn.callCount, 3, 'should ');
|
||||
t.end();
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue