Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Iterate over the own enumerable properties of an object, and return an object with properties that evaluate to true from the callback. Exit early by returning `false`. JavaScript/Node.js.
The for-own npm package is a utility for iterating over the own enumerable properties of an object. It provides a simple and efficient way to loop through an object's properties, executing a callback function for each property.
Iterate over object properties
This feature allows you to iterate over the own enumerable properties of an object. The callback function receives the value and key of each property.
const forOwn = require('for-own');
const obj = { a: 1, b: 2, c: 3 };
forOwn(obj, function(value, key) {
console.log(key + ': ' + value);
});
Early exit from iteration
This feature allows you to exit the iteration early by returning false from the callback function. In this example, the iteration stops when the key 'b' is encountered.
const forOwn = require('for-own');
const obj = { a: 1, b: 2, c: 3 };
forOwn(obj, function(value, key) {
if (key === 'b') return false;
console.log(key + ': ' + value);
});
Lodash is a modern JavaScript utility library delivering modularity, performance, and extras. It includes a `forOwn` method that provides similar functionality to the for-own package, but with additional features and optimizations.
Underscore is a JavaScript library that provides a whole mess of useful functional programming helpers without extending any built-in objects. It includes a `_.each` method that can be used to iterate over object properties, similar to for-own.
The object-keys package is a simple utility that provides a method to get the own enumerable property names of an object. While it doesn't provide iteration directly, it can be used in conjunction with a loop to achieve similar functionality to for-own.
Iterate over the own enumerable properties of an object, and return an object with properties that evaluate to true from the callback. Exit early by returning
false
. JavaScript/Node.js.
Install with npm:
$ npm install --save for-own
var forOwn = require('for-own');
var obj = {a: 'foo', b: 'bar', c: 'baz'};
var values = [];
var keys = [];
forOwn(obj, function (value, key, o) {
keys.push(key);
values.push(value);
});
console.log(keys);
//=> ['a', 'b', 'c'];
console.log(values);
//=> ['foo', 'bar', 'baz'];
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Commits | Contributor |
---|---|
10 | jonschlinkert |
1 | javiercejudo |
(This project's readme.md is generated by verb, please don't edit the readme directly. Any changes to the readme must be made in the .verb.md readme template.)
To generate the readme, run the following command:
$ npm install -g verbose/verb#dev verb-generate-readme && verb
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
$ npm install && npm test
Jon Schlinkert
Copyright © 2017, Jon Schlinkert. Released under the MIT License.
This file was generated by verb-generate-readme, v0.4.2, on February 26, 2017.
FAQs
Iterate over the own enumerable properties of an object, and return an object with properties that evaluate to true from the callback. Exit early by returning `false`. JavaScript/Node.js.
The npm package for-own receives a total of 5,230,329 weekly downloads. As such, for-own popularity was classified as popular.
We found that for-own demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.