New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ml-array-sequential-fill

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ml-array-sequential-fill - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

src/__tests__/sequentialFill.test.js

8

CHANGELOG.md

@@ -6,2 +6,10 @@ # Change Log

# [1.1.0](https://github.com/mljs/array/compare/ml-array-sequential-fill@1.0.1...ml-array-sequential-fill@1.1.0) (2018-10-26)
**Note:** Version bump only for package ml-array-sequential-fill
<a name="1.0.1"></a>

@@ -8,0 +16,0 @@ ## 1.0.1 (2018-08-03)

40

lib/index.js
'use strict';
function _interopDefault (ex) { return (ex && (typeof ex === 'object') && 'default' in ex) ? ex['default'] : ex; }
var isArray = _interopDefault(require('is-any-array'));
/**

@@ -14,3 +18,3 @@ * Fill an array with sequential numbers

function sequentialFill(input = [], options = {}) {
if (typeof input === 'object' && !Array.isArray(input)) {
if (typeof input === 'object' && !isArray(input)) {
options = input;

@@ -20,15 +24,10 @@ input = [];

if (!Array.isArray(input)) {
throw new Error('input must be an array');
if (!isArray(input)) {
throw new TypeError('input must be an array');
}
let {
from = 0,
to = 10,
size = input.length,
step
} = options;
let { from = 0, to = 10, size = input.length, step } = options;
if (size && step) {
size = 0;
throw new Error('step is defined by the array size');
}

@@ -46,7 +45,18 @@

}
input.length = 0;
for (var i = 0; i < size; i++) {
input.push(from);
from += step;
if (Array.isArray(input)) {
input.length = 0; // only works with normal array
for (let i = 0; i < size; i++) {
input.push(from);
from += step;
}
} else {
if (input.length !== size) {
throw new Error(
'sequentialFill typed array must have the correct length'
);
}
for (let i = 0; i < size; i++) {
input[i] = from;
from += step;
}
}

@@ -53,0 +63,0 @@

{
"name": "ml-array-sequential-fill",
"version": "1.0.1",
"version": "1.1.0",
"description": "Create an array with sequential numbers",

@@ -21,3 +21,7 @@ "main": "lib/index.js",

},
"homepage": "https://github.com/mljs/array/tree/master/packages/array-variance#readme"
"homepage": "https://github.com/mljs/array/tree/master/packages/array-variance#readme",
"dependencies": {
"is-any-array": "^0.0.3"
},
"gitHead": "812f53d78df7770c287916b88e94de51815f574b"
}

@@ -0,1 +1,3 @@

import isArray from 'is-any-array';
/**

@@ -12,3 +14,3 @@ * Fill an array with sequential numbers

export default function sequentialFill(input = [], options = {}) {
if (typeof input === 'object' && !Array.isArray(input)) {
if (typeof input === 'object' && !isArray(input)) {
options = input;

@@ -18,15 +20,10 @@ input = [];

if (!Array.isArray(input)) {
throw new Error('input must be an array');
if (!isArray(input)) {
throw new TypeError('input must be an array');
}
let {
from = 0,
to = 10,
size = input.length,
step
} = options;
let { from = 0, to = 10, size = input.length, step } = options;
if (size && step) {
size = 0;
throw new Error('step is defined by the array size');
}

@@ -44,7 +41,18 @@

}
input.length = 0;
for (var i = 0; i < size; i++) {
input.push(from);
from += step;
if (Array.isArray(input)) {
input.length = 0; // only works with normal array
for (let i = 0; i < size; i++) {
input.push(from);
from += step;
}
} else {
if (input.length !== size) {
throw new Error(
'sequentialFill typed array must have the correct length'
);
}
for (let i = 0; i < size; i++) {
input[i] = from;
from += step;
}
}

@@ -51,0 +59,0 @@

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