Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

intervals-fn

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

intervals-fn - npm Package Compare versions

Comparing version 2.8.1 to 2.8.2

10

dist/lib.js

@@ -330,14 +330,14 @@ "use strict";

return ramda_1.chain((i => {
return ramda_1.chain((int => [
return ramda_1.chain((int => isOverlappingSimple(int, numberToRange(i)) ? [
Object.assign({}, int, { start: int.start, end: i }),
Object.assign({}, int, { start: i, end: int.end }),
]), intervals.filter(int => isOverlappingSimple(int, numberToRange(i))));
] : [int]), intervals);
}), splits);
};
const splitCurry = (splitIndexes, intervals) => {
if (Array.isArray(intervals) && intervals.length < 1) {
return [];
}
const typeStr = getType(intervals);
const intervalSE = prepareInput(typeStr, intervals);
if (splitIndexes.length < 1 || Array.isArray(intervals) && intervals.length < 1) {
return intervalSE.map(convertTo(typeStr));
}
return splitGen(splitIndexes, intervalSE).map(convertTo(typeStr));

@@ -344,0 +344,0 @@ };

@@ -40,2 +40,5 @@ "use strict";

t.is(i.end, vals[1], `test interval: ${i}`);
if (!extra) {
return;
}
Object.entries(extra).forEach(([key, val]) => {

@@ -387,11 +390,17 @@ t.true(i.hasOwnProperty(key) && Reflect.get(i, key) === val, `test interval: ${i}, with prop: ${key}:${val}`);

});
ava_1.default('will split intervals', t => {
const r1 = [{ start: 0, end: 7, test: 'foo' }, { start: 3, end: 8, test: 'bar' }];
const r2 = [5];
ava_1.default('will not split when no indexes', t => {
const r1 = [{ start: 0, end: 7, test: 'foo' }];
const r2 = [];
const res = lib_1.split(r2, r1);
t.is(res.length, 4);
testInterval(t, res[0], [0, 5], { test: 'foo' });
testInterval(t, res[1], [5, 7], { test: 'foo' });
testInterval(t, res[2], [3, 5], { test: 'bar' });
testInterval(t, res[3], [5, 8], { test: 'bar' });
t.is(res.length, 1);
testInterval(t, res[0], [0, 7], { test: 'foo' });
});
ava_1.default('will not split when no intersection', t => {
const r1 = [{ start: 0, end: 7, test: 'foo' }, { start: 8, end: 10 }];
const r2 = [9];
const res = lib_1.split(r2, r1);
t.is(res.length, 3);
testInterval(t, res[0], [0, 7], { test: 'foo' });
testInterval(t, res[1], [8, 9]);
testInterval(t, res[2], [9, 10]);
});

@@ -314,14 +314,14 @@ var __rest = (this && this.__rest) || function (s, e) {

return chain((i => {
return chain((int => [
return chain((int => isOverlappingSimple(int, numberToRange(i)) ? [
Object.assign({}, int, { start: int.start, end: i }),
Object.assign({}, int, { start: i, end: int.end }),
]), intervals.filter(int => isOverlappingSimple(int, numberToRange(i))));
] : [int]), intervals);
}), splits);
};
const splitCurry = (splitIndexes, intervals) => {
if (Array.isArray(intervals) && intervals.length < 1) {
return [];
}
const typeStr = getType(intervals);
const intervalSE = prepareInput(typeStr, intervals);
if (splitIndexes.length < 1 || Array.isArray(intervals) && intervals.length < 1) {
return intervalSE.map(convertTo(typeStr));
}
return splitGen(splitIndexes, intervalSE).map(convertTo(typeStr));

@@ -328,0 +328,0 @@ };

@@ -38,2 +38,5 @@ import test from 'ava';

t.is(i.end, vals[1], `test interval: ${i}`);
if (!extra) {
return;
}
Object.entries(extra).forEach(([key, val]) => {

@@ -385,11 +388,17 @@ t.true(i.hasOwnProperty(key) && Reflect.get(i, key) === val, `test interval: ${i}, with prop: ${key}:${val}`);

});
test('will split intervals', t => {
const r1 = [{ start: 0, end: 7, test: 'foo' }, { start: 3, end: 8, test: 'bar' }];
const r2 = [5];
test('will not split when no indexes', t => {
const r1 = [{ start: 0, end: 7, test: 'foo' }];
const r2 = [];
const res = split(r2, r1);
t.is(res.length, 4);
testInterval(t, res[0], [0, 5], { test: 'foo' });
testInterval(t, res[1], [5, 7], { test: 'foo' });
testInterval(t, res[2], [3, 5], { test: 'bar' });
testInterval(t, res[3], [5, 8], { test: 'bar' });
t.is(res.length, 1);
testInterval(t, res[0], [0, 7], { test: 'foo' });
});
test('will not split when no intersection', t => {
const r1 = [{ start: 0, end: 7, test: 'foo' }, { start: 8, end: 10 }];
const r2 = [9];
const res = split(r2, r1);
t.is(res.length, 3);
testInterval(t, res[0], [0, 7], { test: 'foo' });
testInterval(t, res[1], [8, 9]);
testInterval(t, res[2], [9, 10]);
});
{
"name": "intervals-fn",
"version": "2.8.1",
"version": "2.8.2",
"description": "Manipulate intervals in a functional way",

@@ -5,0 +5,0 @@ "main": "dist/lib.js",

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