2020-12-10 07:30:41 +01:00
|
|
|
// object-values | MIT | github.com/tc39/proposal-object-values-entries
|
|
|
|
|
2020-12-10 07:38:12 +01:00
|
|
|
const reduce = Function.bind.call(Function.call, Array.prototype.reduce);
|
|
|
|
const isEnumerable = Function.bind.call(Function.call, Object.prototype.propertyIsEnumerable);
|
|
|
|
const concat = Function.bind.call(Function.call, Array.prototype.concat);
|
|
|
|
|
2020-12-10 07:30:41 +01:00
|
|
|
if (!Object.values) {
|
|
|
|
Object.values = function values(O) {
|
2020-12-10 07:38:12 +01:00
|
|
|
return reduce(Object.keys(O), (v, k) => concat(v, typeof k === 'string' && isEnumerable(O, k) ? [O[k]] : []), []);
|
2020-12-10 07:30:41 +01:00
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!Object.entries) {
|
|
|
|
Object.entries = function entries(O) {
|
2020-12-10 07:38:12 +01:00
|
|
|
return reduce(Object.keys(O), (e, k) => concat(e, typeof k === 'string' && isEnumerable(O, k) ? [[k, O[k]]] : []), []);
|
2020-12-10 07:30:41 +01:00
|
|
|
};
|
|
|
|
}
|