Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
drange
Advanced tools
Readme
For adding/subtracting sets of range of numbers.
const DRange = require('drange');
let allNums = new DRange(1, 100); //[ 1-100 ]
let badNums = DRange(13).add(8).add(60,80); //[8, 13, 60-80]
let goodNums = allNums.clone().subtract(badNums);
console.log(goodNums.toString()); //[ 1-7, 9-12, 14-59, 81-100 ]
let randomGoodNum = goodNums.index(Math.floor(Math.random() * goodNums.length));
Creates a new instance of DRange.
The total length of all subranges
Adds a subrange
Adds all of another DRange's subranges
Subtracts a subrange
Subtracts all of another DRange's subranges
Keep only subranges that overlap the given subrange
Intersect all of another DRange's subranges
Get the number at the specified index
let drange = new DRange()
drange.add(1, 10);
drange.add(21, 30);
console.log(drange.index(15)); // 25
Get contained numbers
let drange = new DRange(1, 4)
drange.add(6);
drange.subtract(2);
console.log(drange.numbers()); // [1, 3, 4, 6]
Get copy of subranges
let drange = new DRange(1, 4)
drange.add(6, 8);
console.log(drange.subranges());
/*
[
{ low: 1, high: 4, length: 4 },
{ low: 6, high: 8, length: 3 }
]
*/
Clones the drange, so that changes to it are not reflected on its clone
npm install drange
Tests are written with mocha
npm test
DRange includes TypeScript definitions.
import * as DRange from "drange";
const range: DRange = new Drange(2, 5);
Use dtslint to check the definition file.
npm install -g dtslint
npm run dtslint
FAQs
For adding, subtracting, and indexing discontinuous ranges of numbers
The npm package drange receives a total of 628,042 weekly downloads. As such, drange popularity was classified as popular.
We found that drange 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
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.