concat-arrays
Advanced tools
Comparing version 1.0.3 to 2.0.0
@@ -1,10 +0,17 @@ | ||
var assert = require('assert') | ||
var concat = require('./') | ||
var start = process.hrtime() | ||
for(var i=0; i<100000000; i++) concat(['a', 'd'], [1], [2]) | ||
var end = process.hrtime(start) | ||
/* eslint-disable no-console */ | ||
const concat = require('./') | ||
benchmark('concat-arrays', function () { concat(['a', 'd'], [1], [2]) }) | ||
benchmark('native concat', function () { [].concat(['a', 'd'], [1], [2]) }) | ||
var ns = end[0] * 1e9 + end[1] | ||
var ms = ns / 1e6 | ||
console.log('END') | ||
console.log('%s milliseconds', ms) | ||
function benchmark (name, method) { | ||
const start = process.hrtime() | ||
for (let i = 0; i < 100000000; i++) method() | ||
const end = process.hrtime(start) | ||
const ns = (end[0] * 1e9) + end[1] | ||
const ms = ns / 1e6 | ||
console.log('%s took %s milliseconds', name, ms) | ||
} |
17
index.js
module.exports = concatArrays | ||
function concatArrays () { | ||
var concatenated = [] | ||
var array | ||
var index = 0 | ||
const concatenated = [] | ||
let array | ||
for (var a = 0, alen = arguments.length; a < alen; a++) { | ||
array = arguments[a] | ||
if (!(array && array.length)) continue | ||
for (var b = 0, blen = array.length; b < blen; b++) { | ||
concatenated[index++] = array[b] | ||
} | ||
for (let a = 0, alen = arguments.length; a < alen; a++) { | ||
array = arguments[a] | ||
if (!(array && array.length)) continue | ||
for (let b = 0, blen = array.length; b < blen; b++) { | ||
concatenated.push(array[b]) | ||
} | ||
} | ||
@@ -15,0 +14,0 @@ |
{ | ||
"name": "concat-arrays", | ||
"version": "1.0.3", | ||
"version": "2.0.0", | ||
"description": "Concatenates arrays or array-like objects (arguments)", | ||
@@ -25,3 +25,17 @@ "keywords": [ | ||
}, | ||
"homepage": "https://github.com/marcbachmann/concat-arrays#readme" | ||
"homepage": "https://github.com/marcbachmann/concat-arrays#readme", | ||
"release": { | ||
"extends": "@livingdocs/semantic-release-presets/npm-github" | ||
}, | ||
"ci": { | ||
"isCi": true, | ||
"name": "Drone", | ||
"service": "drone", | ||
"commit": "0550fab55460abacb245b7eb6b360937314d4b9c", | ||
"build": "7", | ||
"branch": "master", | ||
"isPr": false, | ||
"slug": "marcbachmann/concat-arrays", | ||
"date": "2019-03-16T15:08:21.097Z" | ||
} | ||
} |
# concat-arrays | ||
[![Greenkeeper badge](https://badges.greenkeeper.io/marcbachmann/concat-arrays.svg)](https://greenkeeper.io/) | ||
Concatenates arrays or array-like objects (arguments) | ||
@@ -4,0 +6,0 @@ |
@@ -1,6 +0,6 @@ | ||
var assert = require('assert') | ||
var concat = require('./') | ||
const assert = require('assert') | ||
const concat = require('./') | ||
// Does not modify original array | ||
var arr = [1, 2] | ||
const arr = [1, 2] | ||
assert.notEqual(concat(arr), arr) | ||
@@ -7,0 +7,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9815
7
243
24
1