Security News
JSR Working Group Kicks Off with Ambitious Roadmap and Plans for Open Governance
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
The es5-ext package is a collection of ECMAScript 5 extensions. It provides polyfills for some of the newer ECMAScript features, as well as additional utility functions that enhance the JavaScript standard library.
Array polyfills and extensions
Adds new methods to the Array prototype, such as 'contains', which checks if an array includes a certain element.
[1, 2, 3].contains(2)
Object polyfills and extensions
Introduces new functions to work with objects, like 'isObject', which determines if a value is an object.
Object.isObject({})
String polyfills and extensions
Provides additional methods for strings, for instance, 'startsWith', which checks if a string starts with the specified characters.
'hello'.startsWith('he')
Function polyfills and extensions
Enhances functions with extra capabilities such as 'noop', which is an empty function that does nothing.
(function () {}).noop()
Number polyfills and extensions
Offers new properties and methods for numbers, like 'isFinite', which checks if a value is a finite number.
Number.isFinite(Infinity)
Core-js is a modular standard library for JavaScript, which includes polyfills for ECMAScript up to 2021. It's more comprehensive than es5-ext, covering a wider range of ECMAScript features.
Lodash is a utility library that provides a lot of the same functionality as es5-ext, such as working with arrays, objects, and functions. It is known for its performance and consistency across browsers.
Underscore.js is a utility library that offers similar functionality to es5-ext, with a focus on functional programming. It's often compared to lodash, and while it has many of the same functions, it has a smaller footprint.
Useful methods, functions and objects that are not part of the standard.
Can be used in any environment that implements EcmaScript 5th edition.
Many extensions will also work with ECMAScript 3rd edition, if they're not let es5-shim be your aid.
To use it with node:
$ npm install es5-ext
For browser, you can easily create custom toolset with help of modules-webmake
All utitlities are written with ES5 conventions in mind. It means we mainly deal with methods (not functions) which can directly be assigned to any ES native object's prototype, e.g.:
Function.prototype.curry = require('es5-ext/lib/Function/prototype/curry');
Array.prototype.flatten = require('es5-ext/lib/Array/prototype/flatten');
String.prototype.startsWith = require('es5-ext/lib/String/prototype/starts-with');
However in general extending prototypes of native objects is discouraged, I'd say it's ok only if you own the context (see extending-javascript-natives for more views on that matter).
So when you don't want to extend native prototypes, you can use methods as functions:
var util = {};
var call = Function.prototype.call;
util.curry = call.bind(require('es5-ext/lib/Function/prototype/curry'));
util.flatten = call.bind(require('es5-ext/lib/Array/prototype/flatten'));
util.startsWith = call.bind(require('es5-ext/lib/String/prototype/starts-with'));
Each extension is documented at begin of its source file.
assertNotNull(arg)
getNextIdGenerator([prefix[, postfix]])
global
guid()
isPrimitive(arg)
reserved
toObject(arg)
Array.generate(length, fill0[, fill1[, ...]])
Same as with standarized ES methods, following methods are generic and can be called on any object.
Array.prototype.bsearchClosest(compareFn)
Array.prototype.clear()
Array.prototype.commonLeft(list0[, list1[, ...]])
Array.prototype.compact()
Array.prototype.contains(searchElement)
Array.prototype.copy()
Array.prototype.diff(other)
Array.prototype.exclusion(list0[, list1[, ...]])
Array.prototype.find(query[, thisArg])
Array.prototype.first()
Array.prototype.flatten()
Array.prototype.forEachRight(cb[, thisArg])
Array.prototype.group(cb[, thisArg])
Array.prototype.indexesOf(searchElement[, fromIndex])
Array.prototype.intersection(list0[, list1[, ...]])
Array.prototype.peek()
Array.prototype.remove(value)
Array.prototype.someRight(cb[, thisArg])
Array.prototype.someValue(cb[, thisArg])
Array.prototype.uniq()
Boolean.isBoolean(arg)
Date.getFormat(pattern)
Date.isDate(arg)
Date.prototype.copy(date)
Date.prototype.duration(to)
Date.prototype.floorDay()
Date.prototype.floorMonth()
Date.prototype.floorYear()
Date.prototype.monthDaysCount()
Error.isError(arg)
Error.prototype.throw()
Function.arguments([arg0[, arg1[, ...]])
Function.context()
Function.i(arg)
Function.insert(name, value)
Function.invoke(name[, arg0[, arg1[, ...]]])
Function.isArguments(arg)
Function.isFunction(arg)
Function.k(arg)
Function.memoize(fn[, length[, resolvers]])
Function.noop()
Function.pluck(name)
Function.remove(name)
Function.prototype.aritize(n)
Function.prototype.chain(fn0[, fn1[, ...]])
Function.prototype.curry([arg0[, arg1[, ...])
Function.prototype.flip()
Function.prototype.hold([n[, arg0[, arg1[, ...]]]])
Function.prototype.lock([arg0[, arg1[, ...])
Function.prototype.log(log)
Function.prototype.match()
Function.prototype.ncurry([n[, arg0[, arg1[, ...]])
Function.prototype.not()
Function.prototype.rcurry([arg0[, arg1[, ...])
Function.prototype.rncurry([n[, arg0[, arg1[, ...]])
Function.prototype.s(fn)
Function.prototype.silent([arg0[, arg1[, ...])
Number.getAutoincrement(start, step)
Number.getPad(length[, precision])
Number.isNumber(arg)
Number.prototype.isLessOrEqual(n)
Number.prototype.isLess(n)
Number.prototype.subtract(n)
Object.assertCallable(arg)
Object.getCompareBy(name)
Object.getSet(value)
Object.isCallable(arg)
Object.isList(arg)
Object.isObject(arg)
Object.isPlainObject(arg)
Shortcuts for building descriptors
Object.descriptors.c(valueOrGet[, set])
Object.descriptors.ce(valueOrGet[, set])
Object.descriptors.cew(value)
Object.descriptors.cw(value)
Object.descriptors.e(valueOrGet[, set])
Object.descriptors.ew(value)
Object.descriptors.v(valueOrGet[, set])
Object.descriptors.w()
Object.bindMethods([p[, q]])
Object.every(f[, p])
Object.extend(o)
Object.invoke(args)
Object.mapToArray(cb[, scope])
Object.mergeDeep(o)
Object.merge(p)
Object.pluck(name)
Object.sameType(x)
Object.same()
Object.toDescriptor()
Object.toDescriptors()
Object.toString()
Following are about hash'es (simple enumerable key value pairs)
Object.plain.clone()
Object.plain.compare(p)
Object.plain.elevate([p])
Object.plain.every(f[, p])
Object.plain.filter(f[, p])
Object.plain.forEach(f[, p])
Object.plain.isEmpty()
Object.plain.isPlainObject()
Object.plain.link(p)
Object.plain.map(f[, p])
Object.plain.merge(p)
Object.plain.pluck(name)
Object.plain.same()
Object.plain.setTrue()
Object.plain.setValue(value)
Object.plain.set()
Object.plain.values()
String.endsWith(s)
String.format(map)
String.indent()
String.pad(n)
String.repeat(n)
String.startsWith(s)
String.trimLeftStr(s)
String.trimRightStr(s)
String.convert.dashToCamelCase(str)
FAQs
ECMAScript extensions and shims
The npm package es5-ext receives a total of 6,518,799 weekly downloads. As such, es5-ext popularity was classified as popular.
We found that es5-ext 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
At its inaugural meeting, the JSR Working Group outlined plans for an open governance model and a roadmap to enhance JavaScript package management.
Security News
Research
An advanced npm supply chain attack is leveraging Ethereum smart contracts for decentralized, persistent malware control, evading traditional defenses.
Security News
Research
Attackers are impersonating Sindre Sorhus on npm with a fake 'chalk-node' package containing a malicious backdoor to compromise developers' projects.