Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@types/underscore

Package Overview
Dependencies
Maintainers
1
Versions
87
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@types/underscore

TypeScript definitions for underscore

  • 1.13.0
  • ts4.8
  • ts4.9
  • ts5.0
  • ts5.1
  • ts5.2
  • ts5.3
  • ts5.4
  • ts5.5
  • ts5.6
  • ts5.7
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
746K
decreased by-3.11%
Maintainers
1
Weekly downloads
 
Created

What is @types/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.

What are @types/underscore's main functionalities?

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

Other packages similar to @types/underscore

FAQs

Package last updated on 19 Oct 2024

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc