Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

lomit

Package Overview
Dependencies
Maintainers
1
Versions
16
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lomit - npm Package Compare versions

Comparing version 0.1.1 to 0.2.0

src/index.test.js

33

es/index.js

@@ -1,13 +0,32 @@

var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
export default function omit() {
var obj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
obj = _extends({}, obj);
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
export default function omit(obj, props) {
if (obj === void 0) {
obj = {};
}
if (props === void 0) {
props = [];
}
obj = _objectSpread({}, obj);
props.forEach(function (prop) {
obj.hasOwnProperty(prop) && delete obj[prop];
var deepIndex = prop.indexOf('.');
if (deepIndex !== -1) {
var activeKey = prop.slice(0, deepIndex);
var activeProps = prop.slice(deepIndex + 1);
if (activeKey && obj[activeKey]) {
obj[activeKey] = omit(obj[activeKey], [activeProps]);
}
} else {
obj.hasOwnProperty(prop) && delete obj[prop];
}
});
return obj;
}
"use strict";
exports.__esModule = true;
exports["default"] = omit;
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
exports.default = omit;
function omit() {
var obj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
obj = _extends({}, obj);
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function omit(obj, props) {
if (obj === void 0) {
obj = {};
}
if (props === void 0) {
props = [];
}
obj = _objectSpread({}, obj);
props.forEach(function (prop) {
obj.hasOwnProperty(prop) && delete obj[prop];
var deepIndex = prop.indexOf('.');
if (deepIndex !== -1) {
var activeKey = prop.slice(0, deepIndex);
var activeProps = prop.slice(deepIndex + 1);
if (activeKey && obj[activeKey]) {
obj[activeKey] = omit(obj[activeKey], [activeProps]);
}
} else {
obj.hasOwnProperty(prop) && delete obj[prop];
}
});
return obj;
}
{
"name": "lomit",
"version": "0.1.1",
"version": "0.2.0",
"license": "MIT",
"description": "Lightweight version of object omit.",
"description": "Lightweight version of Object omit.",
"repository": "ryanhefner/lomit",

@@ -12,2 +12,6 @@ "bugs": {

"author": "Ryan Hefner <hi@ryanhefner.com> (https://www.ryanhefner.com)",
"keywords": [
"omit",
"lodash"
],
"files": [

@@ -29,24 +33,37 @@ "index.js",

"build": "node ./tools/build.js",
"watch": "babel ./src -d . --ignore __tests__ --watch",
"watch": "babel ./src -d . --ignore __tests__,**/*.test.js --watch",
"prepare": "npm run build",
"prepublishOnly": "node ./tools/build.js",
"push-release": "git push origin master && git push --tags",
"test": "echo \"Error: no test specified\" && exit 1"
"test": "jest"
},
"devDependencies": {
"babel-cli": "^6.26.0",
"@babel/cli": "^7.8.4",
"@babel/core": "^7.8.7",
"@babel/plugin-proposal-object-rest-spread": "^7.8.3",
"@babel/preset-env": "^7.8.7",
"babel-core": "^7.0.0-bridge.0",
"babel-jest": "^25.1.0",
"babel-plugin-dev-expression": "^0.2.1",
"babel-plugin-external-helpers": "^6.22.0",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-preset-env": "^1.6.0",
"gzip-size": "^4.0.0",
"pretty-bytes": "^4.0.2",
"rollup": "^0.49.3",
"rollup-plugin-babel": "^3.0.2",
"rollup-plugin-commonjs": "^8.2.1",
"rollup-plugin-json": "^2.3.0",
"rollup-plugin-node-resolve": "^3.0.0",
"rollup-plugin-uglify": "^2.0.1",
"coveralls": "^3.0.9",
"greenkeeper-lockfile": "^1.15.1",
"gzip-size": "^5.1.1",
"jest": "^25.1.0",
"pretty-bytes": "^5.3.0",
"rollup": "^2.0.0",
"rollup-plugin-babel": "^4.3.3",
"rollup-plugin-commonjs": "^10.1.0",
"rollup-plugin-json": "^4.0.0",
"rollup-plugin-node-resolve": "^5.2.0",
"rollup-plugin-uglify": "^6.0.4",
"rollup-watch": "^4.3.1"
},
"jest": {
"collectCoverage": true,
"collectCoverageFrom": [
"src/**/*.js",
"!src/**/*.test.js"
]
}
}
# lomit
[![npm](https://img.shields.io/npm/v/lomit?style=flat-square)](https://github.com/ryanhefner/lomit)
[![NPM](https://img.shields.io/npm/l/lomit?style=flat-square)](LICENSE)
[![npm](https://img.shields.io/npm/dt/lomit?style=flat-square)](https://www.npmjs.com/package/lomit)
![Coveralls github](https://img.shields.io/coveralls/github/ryanhefner/lomit?style=flat-square)
![CircleCI](https://img.shields.io/circleci/build/github/ryanhefner/lomit?style=flat-square)
![Snyk Vulnerabilities for GitHub Repo](https://img.shields.io/snyk/vulnerabilities/github/ryanhefner/lomit?style=flat-square)
Lightweight function for omitting properties from an object.

@@ -25,7 +32,22 @@

omit({name: '', title: ''}, ['title']);
```
```sh
Output: {name: ''}
```
### Deep omits (*__New!__*)
```js
import omit from 'lomit';
omit({name: '', title: '', location: { city: '', state: '' }}, ['title', 'location.city']);
```
```sh
Output: {name: '', location: { state: '' }}
```
## License
[MIT](LICENSE) © [Ryan Hefner](https://www.ryanhefner.com)
export default function omit(obj = {}, props = []) {
obj = {...obj};
props.forEach((prop) => {
obj.hasOwnProperty(prop) && delete(obj[prop]);
const deepIndex = prop.indexOf('.');
if (deepIndex !== -1) {
const activeKey = prop.slice(0, deepIndex);
const activeProps = prop.slice(deepIndex + 1);
if (activeKey && obj[activeKey]) {
obj[activeKey] = omit(obj[activeKey], [activeProps]);
}
} else {
obj.hasOwnProperty(prop) && delete(obj[prop]);
}
});

@@ -6,0 +17,0 @@

@@ -1,164 +0,44 @@

/*! lomit v0.1.1 | (c) 2017 Ryan Hefner | MIT License | https://github.com/ryanhefner/lomit !*/
/*! lomit v0.2.0 | (c) 2020 Ryan Hefner | MIT License | https://github.com/ryanhefner/lomit !*/
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global.lomit = factory());
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = global || self, global.lomit = factory());
}(this, (function () { 'use strict';
var asyncGenerator = function () {
function AwaitValue(value) {
this.value = value;
}
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
function AsyncGenerator(gen) {
var front, back;
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
function send(key, arg) {
return new Promise(function (resolve, reject) {
var request = {
key: key,
arg: arg,
resolve: resolve,
reject: reject,
next: null
};
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
if (back) {
back = back.next = request;
} else {
front = back = request;
resume(key, arg);
}
});
function omit(obj, props) {
if (obj === void 0) {
obj = {};
}
function resume(key, arg) {
try {
var result = gen[key](arg);
var value = result.value;
if (value instanceof AwaitValue) {
Promise.resolve(value.value).then(function (arg) {
resume("next", arg);
}, function (arg) {
resume("throw", arg);
});
} else {
settle(result.done ? "return" : "normal", result.value);
}
} catch (err) {
settle("throw", err);
}
if (props === void 0) {
props = [];
}
function settle(type, value) {
switch (type) {
case "return":
front.resolve({
value: value,
done: true
});
break;
obj = _objectSpread({}, obj);
props.forEach(function (prop) {
var deepIndex = prop.indexOf('.');
case "throw":
front.reject(value);
break;
if (deepIndex !== -1) {
var activeKey = prop.slice(0, deepIndex);
var activeProps = prop.slice(deepIndex + 1);
default:
front.resolve({
value: value,
done: false
});
break;
}
front = front.next;
if (front) {
resume(front.key, front.arg);
if (activeKey && obj[activeKey]) {
obj[activeKey] = omit(obj[activeKey], [activeProps]);
}
} else {
back = null;
obj.hasOwnProperty(prop) && delete obj[prop];
}
}
this._invoke = send;
if (typeof gen.return !== "function") {
this.return = undefined;
}
});
return obj;
}
if (typeof Symbol === "function" && Symbol.asyncIterator) {
AsyncGenerator.prototype[Symbol.asyncIterator] = function () {
return this;
};
}
return omit;
AsyncGenerator.prototype.next = function (arg) {
return this._invoke("next", arg);
};
AsyncGenerator.prototype.throw = function (arg) {
return this._invoke("throw", arg);
};
AsyncGenerator.prototype.return = function (arg) {
return this._invoke("return", arg);
};
return {
wrap: function (fn) {
return function () {
return new AsyncGenerator(fn.apply(this, arguments));
};
},
await: function (value) {
return new AwaitValue(value);
}
};
}();
var _extends = Object.assign || function (target) {
for (var i = 1; i < arguments.length; i++) {
var source = arguments[i];
for (var key in source) {
if (Object.prototype.hasOwnProperty.call(source, key)) {
target[key] = source[key];
}
}
}
return target;
};
function omit() {
var obj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var props = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
obj = _extends({}, obj);
props.forEach(function (prop) {
obj.hasOwnProperty(prop) && delete obj[prop];
});
return obj;
}
return omit;
})));
/* follow me on Twitter! @ryanhefner */

@@ -1,1 +0,1 @@

!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.lomit=e()}(this,function(){"use strict";!function(){function t(t){this.value=t}function e(e){function n(r,i){try{var u=e[r](i),c=u.value;c instanceof t?Promise.resolve(c.value).then(function(t){n("next",t)},function(t){n("throw",t)}):o(u.done?"return":"normal",u.value)}catch(t){o("throw",t)}}function o(t,e){switch(t){case"return":r.resolve({value:e,done:!0});break;case"throw":r.reject(e);break;default:r.resolve({value:e,done:!1})}(r=r.next)?n(r.key,r.arg):i=null}var r,i;this._invoke=function(t,e){return new Promise(function(o,u){var c={key:t,arg:e,resolve:o,reject:u,next:null};i?i=i.next=c:(r=i=c,n(t,e))})},"function"!=typeof e.return&&(this.return=void 0)}"function"==typeof Symbol&&Symbol.asyncIterator&&(e.prototype[Symbol.asyncIterator]=function(){return this}),e.prototype.next=function(t){return this._invoke("next",t)},e.prototype.throw=function(t){return this._invoke("throw",t)},e.prototype.return=function(t){return this._invoke("return",t)}}();var t=Object.assign||function(t){for(var e=1;e<arguments.length;e++){var n=arguments[e];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(t[o]=n[o])}return t};return function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return e=t({},e),n.forEach(function(t){e.hasOwnProperty(t)&&delete e[t]}),e}});
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e=e||self).lomit=t()}(this,function(){"use strict";function t(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable})),r.push.apply(r,n)}return r}return function o(i,e){return void 0===i&&(i={}),void 0===e&&(e=[]),i=function(o){for(var e=1;e<arguments.length;e++){var i=null!=arguments[e]?arguments[e]:{};e%2?t(Object(i),!0).forEach(function(e){var t,r,n;t=o,n=i[r=e],r in t?Object.defineProperty(t,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[r]=n}):Object.getOwnPropertyDescriptors?Object.defineProperties(o,Object.getOwnPropertyDescriptors(i)):t(Object(i)).forEach(function(e){Object.defineProperty(o,e,Object.getOwnPropertyDescriptor(i,e))})}return o}({},i),e.forEach(function(e){var t=e.indexOf(".");if(-1!==t){var r=e.slice(0,t),n=e.slice(t+1);r&&i[r]&&(i[r]=o(i[r],[n]))}else i.hasOwnProperty(e)&&delete i[e]}),i}});

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc