crocks
Version:
A collection of well known Algebraic Datatypes for your utter enjoyment.
31 lines (24 loc) • 837 B
JavaScript
/** @license ISC License (c) copyright 2017 original and current authors */
/** @author Ian Hofmann-Hicks (evil) */
var curry = require('../core/curry')
var isFoldable = require('../core/isFoldable')
var isObject = require('../core/isObject')
function omitKeys(keys, obj) {
return function(acc, key) {
var obj$1;
return keys.indexOf(key) === -1 && obj[key] !== undefined
? Object.assign(acc, ( obj$1 = {}, obj$1[key] = obj[key], obj$1 ))
: acc
}
}
// omit : [ String ] -> Object -> Object
function omit(keys, obj) {
if(!isFoldable(keys)) {
throw new TypeError('omit: Foldable required for first argument')
}
else if(!isObject(obj)) {
throw new TypeError('omit: Object required for second argument')
}
return Object.keys(obj).reduce(omitKeys(keys, obj), {})
}
module.exports = curry(omit)