There are 2 ways to install and use the library.
$ npm install --save linear-array
- import with a
<script type="module" src=""></script>
Importing and using in project
Since this package can be used on the client side, as
ES6 module, and server side, as
CommonJS module, there are 2 ways to import it into your .js file:
const lineArr = ;// ...linear; // false
;// ...; // true// OR;// ...lineArr; // true
If you imported the
linear-array library with the
<script> tag it will be attached to the globally available
That's why you can use the module directly in your code by referencing the
lineArr module directly
<!-- index.html --><!-- -->
// custom.jslineArr; // false
Currently, there are 4 methods available in the package.
Based on the differences in their input and output data types, they can be divided into 2 categories;
- inputs / arguments are finite integers, the output value is a filled array of finite integers sorted in an increasing order according to a specific pattern
- input / argument is an array of finite integers, and the output value is a boolean which indicates it the given array conforms to a specific pattern
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.
Sequence of natural numbers
fillSeqNaturalNumbers (limiter: number, [includeLast = false]: boolean) => number
isSeqNaturalNumbers(arr: number) => boolean
=== true || false-> false0 -> true01234 -> true23456 -> false01235 -> false
Sequence of numbers with a specified fixed step and offset
fillStepSequenceWithOffset (limiter: number, [step = 1]: number, [offset = 0]: number) => number
isStepSequenceWithOffset (arr: number, [step = 1]: number, [offset = 0]: number) => boolean
The linearArray method no longer exists and it is not imported directly from the library.
The closes equivalent to the old
linearArray method is now
This update has 4 new methods:
See the Usage section on what they are and how they are used.
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:
💻 🤔 ⚠️