Security News
38% of CISOs Fear They’re Not Moving Fast Enough on AI
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
array.prototype.flatten
Advanced tools
An ESnext spec-compliant `Array.prototype.flatten` shim/polyfill/replacement that works as far down as ES3.
An ESnext spec-compliant Array.prototype.flatten
shim/polyfill/replacement that works as far down as ES3.
This package implements the es-shim API interface. It works in an ES3-supported environment and complies with the proposed spec.
Because Array.prototype.flatten
depends on a receiver (the this
value), the main export takes the array to operate on as the first argument.
npm install --save array.prototype.flatten
var flatten = require('array.prototype.flatten');
var assert = require('assert');
var arr = [1, [2], [], 3, [[4]]];
assert.deepEqual(flatten(arr, 1), [1, 2, 3, [4]]);
var flatten = require('array.prototype.flatten');
var assert = require('assert');
/* when Array#flatten is not present */
delete Array.prototype.flatten;
var shimmedFlatten = flatten.shim();
assert.equal(shimmedFlatten, flatten.getPolyfill());
assert.deepEqual(arr.flatten(), flatten(arr));
var flatten = require('array.prototype.flatten');
var assert = require('assert');
/* when Array#flatten is present */
var shimmedIncludes = flatten.shim();
var mapper = function (x) { return [x, 1]; };
assert.equal(shimmedIncludes, Array.prototype.flatten);
assert.deepEqual(arr.flatten(mapper), flatten(arr, mapper));
Simply clone the repo, npm install
, and run npm test
FAQs
An ESnext spec-compliant `Array.prototype.flatten` shim/polyfill/replacement that works as far down as ES3.
We found that array.prototype.flatten demonstrated a not healthy version release cadence and project activity because the last version was released 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
CISOs are racing to adopt AI for cybersecurity, but hurdles in budgets and governance may leave some falling behind in the fight against cyber threats.
Research
Security News
Socket researchers uncovered a backdoored typosquat of BoltDB in the Go ecosystem, exploiting Go Module Proxy caching to persist undetected for years.
Security News
Company News
Socket is joining TC54 to help develop standards for software supply chain security, contributing to the evolution of SBOMs, CycloneDX, and Package URL specifications.