![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
based-array
Advanced tools
A correct and based array implementation. 1-based indexing. obviously.
A correct and based array implementation. 1-based indexing. obviously.
Inspired by Why you're wrong about 0-based indexing by @tjdevries
npm install --save based-array
yarn add based-array
pnpm add based-array
import { BasedArray } from "based-array";
const funkyReduce = (arr: number[]) => {
return arr.reduce((accum, item, index) => {
return accum + item * index;
}, 0);
};
let array = new BasedArray<number>(5).fill(1);
console.log(array[1]);
// 1
console.log(funkyReduce(array));
// 15
array = BasedArray.from([1, 2, 3, 4, 5]);
console.log(array[1]);
// 1
console.log(funkyReduce(array));
// 55
import { BasedArray } from "based-array";
let array = BasedArray.from([1, 2, 3, 4, 5]);
console.log(array[1]);
// 1
console.log(array[0]);
// undefined
// console.warn: you are counting from zero
BasedArray.strict();
array = BasedArray.from([1, 2, 3, 4, 5]);
console.log(array[1]);
// 1
console.log(array[0]);
// Throws error: CountingFromZeroError
Every based array method is tested against its vanilla counterpart in a thrilling batte over in tests/vanilla-vs.spec.
The example above is tested in tests/readme-example.spec.
You can run a simple performance test.
➜ based-array git:(main) ✗ npm run perf
Starting performance test with 10,000 items.
Vanilla: 0.809ms
Based: 0.657ms
Vanilla: 0.524ms
Based: 0.548ms
Finished performance test.
FAQs
A correct and based array implementation. 1-based indexing. obviously.
The npm package based-array receives a total of 6 weekly downloads. As such, based-array popularity was classified as not popular.
We found that based-array demonstrated a healthy version release cadence and project activity because the last version was released less than 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
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.