3 exports.__esModule = true;
5 var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
8 exports.reduce = reduce;
9 exports.assign = assign;
10 exports.isObject = isObject;
11 exports.isPlain = isPlain;
18 * @callback obj:EachCallback
20 * @param {Mixed} value
21 * The current key for the object that is being iterated over.
24 * The current key-value for object that is being iterated over
28 * @callback obj:ReduceCallback
30 * @param {Mixed} accum
31 * The value that is accumulating over the reduce loop.
33 * @param {Mixed} value
34 * The current key for the object that is being iterated over.
37 * The current key-value for object that is being iterated over
40 * The new accumulated value.
42 var toString = Object.prototype.toString;
45 * Get the keys of an Object
48 * The Object to get the keys from
51 * An array of the keys from the object. Returns an empty array if the
52 * object passed in was invalid or had no keys.
56 var keys = function keys(object) {
57 return isObject(object) ? Object.keys(object) : [];
61 * Array-like iteration for objects.
63 * @param {Object} object
64 * The object to iterate over
66 * @param {obj:EachCallback} fn
67 * The callback function which is called for each key in the object.
69 function each(object, fn) {
70 keys(object).forEach(function (key) {
71 return fn(object[key], key);
76 * Array-like reduce for objects.
78 * @param {Object} object
79 * The Object that you want to reduce.
81 * @param {Function} fn
82 * A callback function which is called for each key in the object. It
83 * receives the accumulated value and the per-iteration value and key
86 * @param {Mixed} [initial = 0]
90 * The final accumulated value.
92 function reduce(object, fn) {
93 var initial = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
95 return keys(object).reduce(function (accum, key) {
96 return fn(accum, object[key], key);
101 * Object.assign-style object shallow merge/extend.
103 * @param {Object} target
104 * @param {Object} ...sources
107 function assign(target) {
108 for (var _len = arguments.length, sources = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
109 sources[_key - 1] = arguments[_key];
113 return Object.assign.apply(Object, [target].concat(sources));
116 sources.forEach(function (source) {
121 each(source, function (value, key) {
130 * Returns whether a value is an object of any kind - including DOM nodes,
131 * arrays, regular expressions, etc. Not functions, though.
133 * This avoids the gotcha where using `typeof` on a `null` value
134 * results in `'object'`.
136 * @param {Object} value
139 function isObject(value) {
140 return !!value && (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object';
144 * Returns whether an object appears to be a "plain" object - that is, a
145 * direct instance of `Object`.
147 * @param {Object} value
150 function isPlain(value) {
151 return isObject(value) && toString.call(value) === '[object Object]' && value.constructor === Object;