UNPKG

788 BJavaScriptView Raw
1'use strict';
2
3Object.defineProperty(exports, '__esModule', { value: true });
4
5/**
6 * Does nothing.
7 */
8function noop() {}
9/**
10 * A function that only returns the first parameter passed to it.
11 * @param {any} x The first parameter
12 * @returns {any}
13 */
14
15function identity(x) {
16 return x;
17}
18/**
19 * Creates a new object from obj that only contains specific keys.
20 * @param {object} obj The source object.
21 * @param {array} keys The keys to pick in the source object.
22 * @returns {object}
23 */
24
25function pick(obj, keys) {
26 return keys.reduce(function (filtered, key) {
27 if (obj[key] !== undefined) {
28 filtered[key] = obj[key];
29 }
30
31 return filtered;
32 }, {});
33}
34
35exports.identity = identity;
36exports.noop = noop;
37exports.pick = pick;
38//# sourceMappingURL=miscellaneous.js.map