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.
@types/underscore
Advanced tools
TypeScript definitions for underscore
@types/underscore provides TypeScript type definitions for the Underscore.js library, which is a utility-belt library for JavaScript that provides a lot of the functional programming support you would expect in Prototype.js (or Ruby), but without extending any of the built-in JavaScript objects.
Array Operations
Underscore provides a variety of functions to manipulate arrays, such as map, filter, reduce, and more. In this example, the map function is used to double each number in the array.
const _ = require('underscore');
const numbers = [1, 2, 3, 4, 5];
const doubled = _.map(numbers, (num) => num * 2);
console.log(doubled); // [2, 4, 6, 8, 10]
Object Operations
Underscore offers several functions to work with objects, such as keys, values, extend, and more. This example demonstrates the keys function, which retrieves all the keys of an object.
const _ = require('underscore');
const person = { name: 'John', age: 30, job: 'Developer' };
const keys = _.keys(person);
console.log(keys); // ['name', 'age', 'job']
Utility Functions
Underscore includes various utility functions like identity, constant, noop, and more. The every function checks if all elements in an array pass a given predicate function.
const _ = require('underscore');
const isEven = (num) => num % 2 === 0;
const result = _.every([2, 4, 6], isEven);
console.log(result); // true
Function Operations
Underscore provides functions to manipulate other functions, such as bind, debounce, throttle, and more. The once function ensures a function is only called once.
const _ = require('underscore');
const greet = (name) => `Hello, ${name}!`;
const greetOnce = _.once(greet);
console.log(greetOnce('John')); // 'Hello, John!'
console.log(greetOnce('Jane')); // undefined
Lodash is a modern JavaScript utility library delivering modularity, performance, and extras. It is similar to Underscore but offers more features and better performance.
Ramda is a practical functional library for JavaScript programmers. It focuses on immutability and side-effect-free functions, providing a more functional approach compared to Underscore.
Lazy.js is a utility library similar to Underscore and Lodash but with a lazy evaluation approach, which can lead to performance improvements in certain scenarios.
npm install --save @types/underscore
This package contains type definitions for underscore (https://underscorejs.org/).
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/underscore.
These definitions were written by Boris Yankov, Josh Baldwin, Christopher Currens, Ard Timmerman, Julian Gonggrijp, Florian Imdahl, Regev Brody, Piotr Błażejewicz, Michael Ness, and Luke Tsekouras.
FAQs
TypeScript definitions for underscore
The npm package @types/underscore receives a total of 470,626 weekly downloads. As such, @types/underscore popularity was classified as popular.
We found that @types/underscore demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer 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.