lodash-omitdeep 1.0.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/README.md ADDED
Binary file
package/lib/index.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ import omitDeep from './omitDeep/omitDeep';
2
+ import omitByDeep from './omitDeepBy/omitDeepBy';
3
+ declare const _default: {
4
+ omitDeep: typeof omitDeep;
5
+ omitByDeep: typeof omitByDeep;
6
+ };
7
+ export = _default;
package/lib/index.js ADDED
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ var omitDeep_1 = __importDefault(require("./omitDeep/omitDeep"));
6
+ var omitDeepBy_1 = __importDefault(require("./omitDeepBy/omitDeepBy"));
7
+ module.exports = { omitDeep: omitDeep_1.default, omitByDeep: omitDeepBy_1.default };
@@ -0,0 +1,21 @@
1
+ import { Many, PropertyName, PartialObject } from 'lodash';
2
+ /**
3
+ * The opposite of `_.pick`; this method creates an object composed of the
4
+ * own and inherited enumerable properties of `object` that are not omitted.
5
+ *
6
+ * @category Object
7
+ * @param object The source object.
8
+ * @param [paths] The property names to omit, specified
9
+ * individually or in arrays..
10
+ * @returns Returns the new object.
11
+ * @example
12
+ *
13
+ * var object = { 'a': 1, 'b': 2, 'c': { 'a': 1, 'b': 2 } };
14
+ *
15
+ * omitDeep(object, ['b', 'a']);
16
+ * // => { 'c': {} }
17
+ */
18
+ declare function omitDeep<T extends object, K extends PropertyName[]>(object: T | null | undefined, ...paths: K): Pick<T, Exclude<keyof T, K[number]>>;
19
+ declare function omitDeep<T extends object, K extends keyof T>(object: T | null | undefined, ...paths: Many<K>[]): Omit<T, K>;
20
+ declare function omitDeep<T extends object>(object: T | null | undefined, ...paths: Many<PropertyName>[]): PartialObject<T>;
21
+ export default omitDeep;
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
3
+ if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
4
+ if (ar || !(i in from)) {
5
+ if (!ar) ar = Array.prototype.slice.call(from, 0, i);
6
+ ar[i] = from[i];
7
+ }
8
+ }
9
+ return to.concat(ar || Array.prototype.slice.call(from));
10
+ };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
14
+ Object.defineProperty(exports, "__esModule", { value: true });
15
+ var lodash_omit_1 = __importDefault(require("lodash.omit"));
16
+ var lodash_isplainobject_1 = __importDefault(require("lodash.isplainobject"));
17
+ var lodash_isnil_1 = __importDefault(require("lodash.isnil"));
18
+ function omitDeep(object) {
19
+ var paths = [];
20
+ for (var _i = 1; _i < arguments.length; _i++) {
21
+ paths[_i - 1] = arguments[_i];
22
+ }
23
+ function omitDeepOnOwnProps(object) {
24
+ if (!Array.isArray(object) && !(0, lodash_isplainobject_1.default)(object)) {
25
+ return object;
26
+ }
27
+ if (Array.isArray(object)) {
28
+ return object.map(function (element) { return (needOmit(element) ? omitDeep.apply(void 0, __spreadArray([element], paths, false)) : element); });
29
+ }
30
+ var temp = {};
31
+ for (var _i = 0, _a = Object.entries(object); _i < _a.length; _i++) {
32
+ var _b = _a[_i], key = _b[0], value = _b[1];
33
+ temp[key] = needOmit(value) ? omitDeep.apply(void 0, __spreadArray([value], paths, false)) : value;
34
+ }
35
+ return lodash_omit_1.default.apply(void 0, __spreadArray([temp], paths, false));
36
+ }
37
+ return omitDeepOnOwnProps(object);
38
+ }
39
+ function needOmit(value) {
40
+ return !(0, lodash_isnil_1.default)(value) && ((0, lodash_isplainobject_1.default)(value) || Array.isArray(value));
41
+ }
42
+ exports.default = omitDeep;
@@ -0,0 +1,21 @@
1
+ import { PartialObject, ValueKeyIteratee, NumericDictionary, Dictionary } from 'lodash';
2
+ /**
3
+ * The opposite of `_.pickBy`; this method creates an object composed of the
4
+ * own and inherited enumerable properties of `object` that `predicate`
5
+ * doesn't return truthy for.
6
+ *
7
+ * @category Object
8
+ * @param object The source object.
9
+ * @param [predicate=_.identity] The function invoked per property.
10
+ * @returns Returns the new object.
11
+ * @example
12
+ *
13
+ * var object = { 'a': 1, 'b': 2, 'c': { 'a': 1, 'b': 2 } };
14
+ *
15
+ * omitByDeep(object, _.isNil);
16
+ * // => { a: 1, c: { a: 1 } }
17
+ */
18
+ declare function omitByDeep<T>(object: Dictionary<T> | null | undefined, predicate?: ValueKeyIteratee<T>): Dictionary<T>;
19
+ declare function omitByDeep<T>(object: NumericDictionary<T> | null | undefined, predicate?: ValueKeyIteratee<T>): NumericDictionary<T>;
20
+ declare function omitByDeep<T extends object>(object: T | null | undefined, predicate: ValueKeyIteratee<T[keyof T]>): PartialObject<T>;
21
+ export default omitByDeep;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ var lodash_omitby_1 = __importDefault(require("lodash.omitby"));
7
+ var lodash_isplainobject_1 = __importDefault(require("lodash.isplainobject"));
8
+ function omitByDeep(object, cb) {
9
+ function omitByDeepByOnOwnProps(object) {
10
+ if (!Array.isArray(object) && !(0, lodash_isplainobject_1.default)(object)) {
11
+ return object;
12
+ }
13
+ if (Array.isArray(object)) {
14
+ return object.map(function (element) { return omitByDeep(element, cb); });
15
+ }
16
+ var temp = {};
17
+ for (var _i = 0, _a = Object.entries(object); _i < _a.length; _i++) {
18
+ var _b = _a[_i], key = _b[0], value = _b[1];
19
+ temp[key] = omitByDeep(value, cb);
20
+ }
21
+ return (0, lodash_omitby_1.default)(temp, cb);
22
+ }
23
+ return omitByDeepByOnOwnProps(object);
24
+ }
25
+ exports.default = omitByDeep;
package/package.json ADDED
@@ -0,0 +1,63 @@
1
+ {
2
+ "name": "lodash-omitdeep",
3
+ "version": "1.0.0",
4
+ "description": "Lodash omitDeep/omitByDeep object key/value recursively",
5
+ "main": "lib/index.js",
6
+ "types": "lib/index.d.ts",
7
+ "keywords": [
8
+ "lodash",
9
+ "omit",
10
+ "omitDeep",
11
+ "omitBy",
12
+ "omitByDeep",
13
+ "key",
14
+ "keys",
15
+ "delete",
16
+ "remove",
17
+ "object",
18
+ "deep"
19
+ ],
20
+ "homepage": "https://github.com/hwapedro/lodash-omit-deep",
21
+ "author": "Dmitriy Babin (https://github.com/hwapedro)",
22
+ "repository": {
23
+ "type": "git",
24
+ "url": "https://github.com/hwapedro/lodash-omit-deep"
25
+ },
26
+ "bugs": {
27
+ "url": "https://github.com/hwapedro/lodash-omit-deep/issues"
28
+ },
29
+ "files": [
30
+ "lib/**/*"
31
+ ],
32
+ "scripts": {
33
+ "build": "tsc --project tsconfig.prod.json",
34
+ "prepublishOnly": "npm test && npm run lint",
35
+ "preversion": "npm run lint",
36
+ "version": "npm run format && git add -A src",
37
+ "prepare": "npm run build",
38
+ "postversion": "git push && git push --tags",
39
+ "format": "prettier --write \"src/**/*.ts\"",
40
+ "lint": "tslint -p tsconfig.json",
41
+ "test": "jest --config jestconfig.json"
42
+ },
43
+ "license": "ISC",
44
+ "devDependencies": {
45
+ "@types/jest": "^27.0.3",
46
+ "@types/lodash.isnil": "^4.0.6",
47
+ "@types/lodash.isplainobject": "^4.0.6",
48
+ "@types/lodash.omit": "^4.5.6",
49
+ "@types/lodash.omitby": "^4.6.6",
50
+ "jest": "^27.4.4",
51
+ "prettier": "^2.5.1",
52
+ "ts-jest": "^27.1.1",
53
+ "tslint": "^6.1.3",
54
+ "tslint-config-prettier": "^1.18.0",
55
+ "typescript": "^4.5.3"
56
+ },
57
+ "dependencies": {
58
+ "lodash.isnil": "^4.0.0",
59
+ "lodash.isplainobject": "^4.0.6",
60
+ "lodash.omit": "^4.5.0",
61
+ "lodash.omitby": "^4.6.0"
62
+ }
63
+ }