feature: common: object.omit -> omit

This commit is contained in:
coderiaser 2026-02-21 17:33:20 +02:00
parent d7214aba70
commit 6d19bf2e14
5 changed files with 33 additions and 4 deletions

View file

@ -8,8 +8,7 @@
"fixture*"
],
"rules": {
"package-json/add-type": "off",
"esm/add-index-to-import": "off"
"package-json/add-type": "off"
},
"match": {
".filesystem.json": {

12
common/omit.js Normal file
View file

@ -0,0 +1,12 @@
const difference = (a, b) => new Set(a).difference(new Set(b));
const {keys} = Object;
export const omit = (a, list) => {
const result = {};
for (const key of difference(keys(a), list)) {
result[key] = a[key];
}
return result;
};

18
common/omit.spec.js Normal file
View file

@ -0,0 +1,18 @@
import {test} from 'supertape';
import {omit} from '#common/omit';
test('cloudcmd: common: omit', (t) => {
const a = {
hello: 1,
world: 2,
};
const result = omit(a, ['world']);
const expected = {
hello: 1,
};
t.deepEqual(result, expected);
t.end();
});

View file

@ -122,7 +122,6 @@
"montag": "^1.2.1",
"nano-memoize": "^3.0.16",
"nomine": "^4.0.0",
"object.omit": "^3.0.0",
"once": "^1.4.0",
"onezip": "^6.0.1",
"open": "^11.0.0",
@ -232,6 +231,7 @@
"#dom/storage": "./client/dom/storage.js",
"#dom/rest": "./client/dom/rest.js",
"#common/util": "./common/util.js",
"#common/omit": "./common/omit.js",
"#common/cloudfunc": "./common/cloudfunc.js",
"#common/entity": "./common/entity.js",
"#server/cloudcmd": "./server/cloudcmd.js"

View file

@ -1,7 +1,7 @@
import currify from 'currify';
import wraptile from 'wraptile';
import squad from 'squad';
import omit from 'object.omit';
import {omit} from '#common/omit';
import log, {
exportStr,
connectedStr,