mirror of
https://github.com/swc-project/swc.git
synced 2024-12-25 14:43:33 +03:00
41 lines
950 B
TypeScript
41 lines
950 B
TypeScript
// Loaded from https://deno.land/x/ramda@v0.27.2/source/omit.js
|
|
|
|
|
|
import _curry2 from './internal/_curry2.js';
|
|
|
|
/**
|
|
* Returns a partial copy of an object omitting the keys specified.
|
|
*
|
|
* @func
|
|
* @memberOf R
|
|
* @since v0.1.0
|
|
* @category Object
|
|
* @sig [String] -> {String: *} -> {String: *}
|
|
* @param {Array} names an array of String property names to omit from the new object
|
|
* @param {Object} obj The object to copy from
|
|
* @return {Object} A new object with properties from `names` not on it.
|
|
* @see R.pick
|
|
* @example
|
|
*
|
|
* R.omit(['a', 'd'], {a: 1, b: 2, c: 3, d: 4}); //=> {b: 2, c: 3}
|
|
*/
|
|
var omit = _curry2(function omit(names, obj) {
|
|
var result = {};
|
|
var index = {};
|
|
var idx = 0;
|
|
var len = names.length;
|
|
|
|
while (idx < len) {
|
|
index[names[idx]] = 1;
|
|
idx += 1;
|
|
}
|
|
|
|
for (var prop in obj) {
|
|
if (!index.hasOwnProperty(prop)) {
|
|
result[prop] = obj[prop];
|
|
}
|
|
}
|
|
return result;
|
|
});
|
|
export default omit;
|