What is @types/lodash?
The @types/lodash package provides TypeScript type definitions for Lodash, a modern JavaScript utility library delivering modularity, performance, & extras. This allows developers to use Lodash in TypeScript projects with type checking and autocompletion features.
What are @types/lodash's main functionalities?
Array manipulation
Lodash provides a wide range of functions to manipulate arrays. The example demonstrates reversing an array.
import _ from 'lodash';
const array = [1, 2, 3, 4, 5];
const reversedArray = _.reverse(array);
console.log(reversedArray); // [5, 4, 3, 2, 1]
Object manipulation
Lodash allows for easy manipulation of objects, such as inverting keys and values in an object.
import _ from 'lodash';
const object = { 'a': 1, 'b': 2 };
const invertedObject = _.invert(object);
console.log(invertedObject); // { '1': 'a', '2': 'b' }
Collection iteration
Lodash provides functions like _.filter for iterating over collections and filtering them based on a condition.
import _ from 'lodash';
const users = [
{ 'user': 'barney', 'age': 36, 'active': true },
{ 'user': 'fred', 'age': 40, 'active': false }
];
const activeUsers = _.filter(users, (user) => user.active);
console.log(activeUsers); // [{ 'user': 'barney', 'age': 36, 'active': true }]
Other packages similar to @types/lodash
ramda
Ramda is a practical functional library for JavaScript programmers. It focuses on allowing functional programming techniques without mutating data. Compared to @types/lodash, Ramda emphasizes a more functional programming approach and immutability.
underscore
Underscore is a utility-belt library for JavaScript that provides functional programming helpers without extending any built-in objects. It's similar to Lodash in functionality but generally has fewer utilities and a smaller footprint. Lodash is often considered as a superset of Underscore with additional features and better performance.
Installation
npm install --save @types/lodash
Summary
This package contains type definitions for Lo-Dash 4.14 (http://lodash.com/).
Details
Files were exported from https://www.github.com/DefinitelyTyped/DefinitelyTyped/tree/types-2.0/lodash
Additional Details
- Last updated: Tue, 22 Nov 2016 20:59:27 GMT
- File structure: UMD
- Library Dependencies: none
- Module Dependencies: none
- Global values: _, add, after, ary, assign, assignIn, assignInWith, assignWith, at, attempt, before, bind, bindAll, bindKey, camelCase, capitalize, castArray, ceil, chain, chunk, clamp, clone, cloneDeep, cloneDeepWith, cloneWith, compact, concat, constant, countBy, create, curry, curryRight, debounce, deburr, defaults, defaultsDeep, defer, delay, difference, differenceBy, differenceWith, drop, dropRight, dropRightWhile, dropWhile, each, eachRight, endsWith, eq, escape, escapeRegExp, every, extend, extendWith, fill, filter, find, findIndex, findKey, findLast, findLastIndex, findLastKey, first, flatMap, flatten, flattenDeep, flattenDepth, flip, floor, flow, flowRight, forEach, forEachRight, forIn, forInRight, forOwn, forOwnRight, fromPairs, functions, functionsIn, get, groupBy, gt, gte, has, hasIn, head, identity, inRange, includes, indexOf, initial, intersection, intersectionBy, intersectionWith, invert, invertBy, invoke, invokeMap, isArguments, isArray, isArrayBuffer, isArrayLike, isArrayLikeObject, isBoolean, isBuffer, isDate, isElement, isEmpty, isEqual, isEqualWith, isError, isFinite, isFunction, isInteger, isLength, isMap, isMatch, isMatchWith, isNaN, isNative, isNil, isNull, isNumber, isObject, isObjectLike, isPlainObject, isRegExp, isSafeInteger, isSet, isString, isSymbol, isTypedArray, isUndefined, isWeakMap, isWeakSet, iteratee, join, kebabCase, keyBy, keys, keysIn, last, lastIndexOf, lowerCase, lowerFirst, lt, lte, map, mapKeys, mapValues, matches, matchesProperty, max, maxBy, mean, memoize, merge, mergeWith, method, methodOf, min, minBy, mixin, negate, noConflict, noop, now, nthArg, omit, omitBy, once, orderBy, over, overArgs, overEvery, overSome, pad, padEnd, padStart, parseInt, partial, partialRight, partition, pick, pickBy, property, propertyOf, pull, pullAll, pullAllBy, pullAt, random, range, rangeRight, rearg, reduce, reduceRight, reject, remove, repeat, replace, rest, result, reverse, round, runInContext, sample, sampleSize, set, setWith, shuffle, size, slice, snakeCase, some, sortBy, sortedIndex, sortedIndexBy, sortedIndexOf, sortedLastIndex, sortedLastIndexBy, sortedLastIndexOf, sortedUniq, sortedUniqBy, split, spread, startCase, startsWith, subtract, sum, sumBy, tail, take, takeRight, takeRightWhile, takeWhile, tap, template, throttle, thru, times, toArray, toInteger, toLength, toLower, toNumber, toPairs, toPairsIn, toPath, toPlainObject, toSafeInteger, toString, toUpper, transform, trim, trimEnd, trimStart, truncate, unary, unescape, union, unionBy, unionWith, uniq, uniqBy, uniqWith, uniqueId, unset, unzip, unzipWith, update, upperCase, upperFirst, values, valuesIn, without, words, wrap, xor, xorBy, xorWith, zip, zipObject, zipWith
Credits
These definitions were written by Brian Zengel https://github.com/bczengel, Ilya Mochalov https://github.com/chrootsu, Stepan Mikhaylyuk https://github.com/stepancar.