Comparing version 0.62.1 to 0.63.0
@@ -1360,2 +1360,37 @@ /** | ||
/** | ||
* forIn Iterates over own and inherited enumerable string keyed properties of an object and invokes | ||
* iteratee for each property. The iteratee is invoked with three arguments: (value, key, object) | ||
* | ||
* @param {Object} object input object | ||
* @param {Function} func function invoked per iteration | ||
* @returns {Object} original object | ||
* | ||
* @example | ||
* const Obj_A = function () { | ||
* this.a = 5; | ||
* this.b = 10; | ||
* } | ||
* Obj_A.prototype.c = 15; | ||
* const result = objects.forIn(new Obj_A, (v, k, o) => console.log(v)); | ||
* console.log(result); | ||
* // 5 | ||
* // 10 | ||
* // 15 | ||
* > { a: 5, b: 10 } | ||
*/ | ||
function forIn (object, func) { | ||
const local = Object.entries(object); | ||
const objProto = Object.getPrototypeOf(object); | ||
const proto = objProto ? Object.entries(objProto) : []; | ||
const entries = new Set([...local, ...proto]); | ||
[...entries].reduce((_, [key, value]) => { | ||
func(value, key, object); | ||
return null; | ||
}, null); | ||
return object; | ||
} | ||
/** | ||
* Has, creates an array of values corresponding to paths of the object | ||
@@ -1648,2 +1683,3 @@ * | ||
findKey: findKey, | ||
forIn: forIn, | ||
has: has, | ||
@@ -1650,0 +1686,0 @@ get: get, |
{ | ||
"name": "absurdum", | ||
"version": "0.62.1", | ||
"version": "0.63.0", | ||
"description": "Reductio Ad Absurdum - The Ridiculous Application of Reduce", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
@@ -138,2 +138,3 @@ [![GitHub Releases](https://img.shields.io/github/release/vanillaes/absurdum.svg)](https://github.com/vanillaes/absurdum/releases) | ||
- [findKey][objects.findKey] | ||
- [forIn][objects.forIn] | ||
- [has][objects.has] | ||
@@ -154,2 +155,3 @@ - [get][objects.get] | ||
[objects.findKey]: ./docs/objects/findKey.md | ||
[objects.forIn]: ./docs/objects/forIn.md | ||
[objects.has]: ./docs/objects/has.md | ||
@@ -156,0 +158,0 @@ [objects.get]: ./docs/objects/get.md |
@@ -5,2 +5,3 @@ export { at } from "./at.js"; | ||
export { findKey } from "./findKey.js"; | ||
export { forIn } from "./forIn.js"; | ||
export { has } from "./has.js"; | ||
@@ -7,0 +8,0 @@ export { get } from "./get.js"; |
@@ -5,2 +5,3 @@ export { at } from './at.js'; | ||
export { findKey } from './findKey.js'; | ||
export { forIn } from './forIn.js'; | ||
export { has } from './has.js'; | ||
@@ -7,0 +8,0 @@ export { get } from './get.js'; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
227303
187
5762
195