diff --git a/.putout.json b/.putout.json index 7c6ef070..7154775a 100644 --- a/.putout.json +++ b/.putout.json @@ -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": { diff --git a/common/omit.js b/common/omit.js new file mode 100644 index 00000000..284c2f5b --- /dev/null +++ b/common/omit.js @@ -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; +}; diff --git a/common/omit.spec.js b/common/omit.spec.js new file mode 100644 index 00000000..ff70541c --- /dev/null +++ b/common/omit.spec.js @@ -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(); +}); diff --git a/package.json b/package.json index 304c2573..0e19e567 100644 --- a/package.json +++ b/package.json @@ -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" diff --git a/server/distribute/export.js b/server/distribute/export.js index 3803ca2a..5e1b54d4 100644 --- a/server/distribute/export.js +++ b/server/distribute/export.js @@ -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,