Skip to content

Commit 6d19bf2

Browse files
committed
feature: common: object.omit -> omit
1 parent d7214ab commit 6d19bf2

5 files changed

Lines changed: 33 additions & 4 deletions

File tree

.putout.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@
88
"fixture*"
99
],
1010
"rules": {
11-
"package-json/add-type": "off",
12-
"esm/add-index-to-import": "off"
11+
"package-json/add-type": "off"
1312
},
1413
"match": {
1514
".filesystem.json": {

common/omit.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
const difference = (a, b) => new Set(a).difference(new Set(b));
2+
const {keys} = Object;
3+
4+
export const omit = (a, list) => {
5+
const result = {};
6+
7+
for (const key of difference(keys(a), list)) {
8+
result[key] = a[key];
9+
}
10+
11+
return result;
12+
};

common/omit.spec.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import {test} from 'supertape';
2+
import {omit} from '#common/omit';
3+
4+
test('cloudcmd: common: omit', (t) => {
5+
const a = {
6+
hello: 1,
7+
world: 2,
8+
};
9+
10+
const result = omit(a, ['world']);
11+
12+
const expected = {
13+
hello: 1,
14+
};
15+
16+
t.deepEqual(result, expected);
17+
t.end();
18+
});

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,6 @@
122122
"montag": "^1.2.1",
123123
"nano-memoize": "^3.0.16",
124124
"nomine": "^4.0.0",
125-
"object.omit": "^3.0.0",
126125
"once": "^1.4.0",
127126
"onezip": "^6.0.1",
128127
"open": "^11.0.0",
@@ -232,6 +231,7 @@
232231
"#dom/storage": "./client/dom/storage.js",
233232
"#dom/rest": "./client/dom/rest.js",
234233
"#common/util": "./common/util.js",
234+
"#common/omit": "./common/omit.js",
235235
"#common/cloudfunc": "./common/cloudfunc.js",
236236
"#common/entity": "./common/entity.js",
237237
"#server/cloudcmd": "./server/cloudcmd.js"

server/distribute/export.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import currify from 'currify';
22
import wraptile from 'wraptile';
33
import squad from 'squad';
4-
import omit from 'object.omit';
4+
import {omit} from '#common/omit';
55
import log, {
66
exportStr,
77
connectedStr,

0 commit comments

Comments
 (0)