mirror of
https://github.com/swc-project/swc.git
synced 2024-12-26 15:12:08 +03:00
bbaf619f63
swc_bundler: - [x] Fix wrapped esms. (denoland/deno#9307) - [x] Make test secure.
37 lines
985 B
TypeScript
37 lines
985 B
TypeScript
// Loaded from https://deno.land/x/ramda@v0.27.2/source/pick.js
|
|
|
|
|
|
import _curry2 from './internal/_curry2.js';
|
|
|
|
|
|
/**
|
|
* Returns a partial copy of an object containing only the keys specified. If
|
|
* the key does not exist, the property is ignored.
|
|
*
|
|
* @func
|
|
* @memberOf R
|
|
* @since v0.1.0
|
|
* @category Object
|
|
* @sig [k] -> {k: v} -> {k: v}
|
|
* @param {Array} names an array of String property names to copy onto a new object
|
|
* @param {Object} obj The object to copy from
|
|
* @return {Object} A new object with only properties from `names` on it.
|
|
* @see R.omit, R.props
|
|
* @example
|
|
*
|
|
* R.pick(['a', 'd'], {a: 1, b: 2, c: 3, d: 4}); //=> {a: 1, d: 4}
|
|
* R.pick(['a', 'e', 'f'], {a: 1, b: 2, c: 3, d: 4}); //=> {a: 1}
|
|
*/
|
|
var pick = _curry2(function pick(names, obj) {
|
|
var result = {};
|
|
var idx = 0;
|
|
while (idx < names.length) {
|
|
if (names[idx] in obj) {
|
|
result[names[idx]] = obj[names[idx]];
|
|
}
|
|
idx += 1;
|
|
}
|
|
return result;
|
|
});
|
|
export default pick;
|