
Security News
Feross on TBPN: How North Korea Hijacked Axios
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.
linear-array
Advanced tools
Returns an array filed with linearly increasing numbers, starting from 0 up to the given value - 1 (without offset), or from 1 to the value itself (with offset).
Javascript / Node.js utility library. Returns a set of utility functions, available through the lineArr namespace, which serve to generate arrays populated with sequences such as natural or stepWithOffset sequence, and to check if an array is a sequence of a certain type (like a natural sequence [0,1,2,3,4]).
There are 2 ways to install and use the library.
$ npm install --save linear-array
<script> tag<script
type="module"
src="https://unpkg.com/linear-array@2.0.0/linear-array.js"
></script>
Since this package can be used on the client side, as UMD or ES6 module, and server side, as CommonJS module, there are 2 ways to import it into your .js file:
CommonJSconst lineArr = require('linear-array');
ES6import lineArr from 'linear-array';
UMDUse the globally available lineArr module directly in your code.
It is being imported from the linear-array liibrary with the <script> tag, and is attached to the globally available window variable.
Currently, there are 4 methods available through the lineArr module / namespace.
Based on the differences in their input and output data types, they can be divided into 2 categories;
But both categories operate on the same pattern of data types, and these patterns can be categorized in a mathematical sense as Sequences.
But, repetition of numbers in the arrays is not allowed.
fillSeqNaturalNumbers (limiter: number, [includeLast = false]: boolean) => number[]fillSeqNaturalNumbers(limiter, inludeLast?) === [0, 1, 2, 3, ... , includeLast ? limiter : (limiter - 1)]
(0) -> []
(7) -> [0, 1, 2, 3, 4, 5, 6]
(7, true) -> [0, 1, 2, 3, 4, 5, 6, 7]
isSeqNaturalNumbers(arr: number[]) => booleanisSeqNaturalNumbers(arr) === true || false
([]) -> false
([0]) -> true
([0,1,2,3,4]) -> true
([2,3,4,5,6]) -> false
([0,1,2,3,5]) -> false
fillStepSequenceWithOffset (limiter: number, [step = 1]: number, [offset = 0]: number) => number[]fillStepSequenceWithOffset(limiter, step?, offset?) === [0+offset, step + offset, 2*step + offset, ..., (limiter - 1)*step + offset]
(0) -> []
(0,1,1) -> []
(1,1,1) -> [1]
(5) -> [0, 1, 2, 3, 4]
(5,1,3) -> [3, 4, 5, 6, 7]
(5,3) -> [0, 3, 6, 9, 12]
(5,2,2) -> [2, 4, 6, 8, 10]
isStepSequenceWithOffset (arr: number[], [step = 1]: number, [offset = 0]: number) => booleanisStepSequenceWithOffset(arr, step?, offset?) === true || false
([]) -> false
([0]) -> true
([0],1,1) -> false
([0,1,2,3,4]) -> true
([0,1,2,3,4], 2) -> false
([0,1,2,3,4], 1, 1) -> false
([1,2,3,4,5], 1, 1) -> true
([6,9,12,15,18], 3, 6) -> true
([5,9,12,15,19], 3, 6) -> false
BREAKING CHANGES:
The linearArray method no longer exists and it is not imported directly from the library.
Instead, a module called lineArr is imported and it contains a set of methods. See the Usage section on what they are and how they are used.
The closes equivalent to the old linearArray method is now fillSeqNaturalNumbers
NEW FEATURES:
This update has 4 new methods which can be accessed through the lineArr module.
lineArr.fillSeqNaturalNumbers
lineArr.isSeqNaturalNumbers
lineArr.fillStepSequenceWithOffset
lineArr.isStepSequenceWithOffset
Pull requests and stars are always welcome. For bugs and feature requests, please create an issue.
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
$ npm install && npm test
Many thanks goes to these people for helping me maintain and upgrade the project:
Amin NAIRI 💻 🤔 ⚠️ |
Ivan Spoljaric
Copyright © 2020, Ivan Spoljaric. Released under the MIT License.
FAQs
Returns an array filed with linearly increasing numbers, starting from 0 up to the given value - 1 (without offset), or from 1 to the value itself (with offset).
The npm package linear-array receives a total of 1 weekly downloads. As such, linear-array popularity was classified as not popular.
We found that linear-array 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
Socket CEO Feross Aboukhadijeh breaks down how North Korea hijacked Axios and what it means for the future of software supply chain security.

Security News
OpenSSF has issued a high-severity advisory warning open source developers of an active Slack-based campaign using impersonation to deliver malware.

Research
/Security News
Malicious packages published to npm, PyPI, Go Modules, crates.io, and Packagist impersonate developer tooling to fetch staged malware, steal credentials and wallets, and enable remote access.