Comparing version 1.0.2 to 1.0.3
{ | ||
"name": "insection", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "A data structure for storing number intervals", | ||
@@ -5,0 +5,0 @@ "main": "lib/insection.js", |
@@ -81,2 +81,26 @@ # Insection | ||
### constructor | ||
Creates a new insection instance. | ||
Signature: | ||
```js | ||
new Insection(); => new Insection(defaultValueComparer); | ||
new Insection(valueComparer); | ||
``` | ||
where `defaultValueComparer` is: | ||
```js | ||
function defaultValueComparer(x, y) { | ||
if (x < y) { return -1; } | ||
if (x > y) { return 1; } | ||
return 0; | ||
} | ||
``` | ||
Values is required to have a total order, if you values does not | ||
support the comparison operators you can specify a valueComparer. | ||
### add | ||
@@ -91,6 +115,10 @@ | ||
insection.add(start, end, value) => insection.add('[', start, end, ']', value); | ||
insection.add('[', start, end, ']', value) => insection.add(Insection.interval('[', start, end, ']'), value); | ||
insection.add('[', start, end, ')', value) => insection.add(Insection.interval('[', start, end, ')'), value); | ||
insection.add('(', start, end, ']', value) => insection.add(Insection.interval('(', start, end, ']'), value); | ||
insection.add('(', start, end, ')', value) => insection.add(Insection.interval('(', start, end, ')'), value); | ||
insection.add('[', start, end, ']', value) => | ||
insection.add(Insection.interval('[', start, end, ']'), value); | ||
insection.add('[', start, end, ')', value) => | ||
insection.add(Insection.interval('[', start, end, ')'), value); | ||
insection.add('(', start, end, ']', value) => | ||
insection.add(Insection.interval('(', start, end, ']'), value); | ||
insection.add('(', start, end, ')', value) => | ||
insection.add(Insection.interval('(', start, end, ')'), value); | ||
insection.add(interval, value); | ||
@@ -150,6 +178,10 @@ ``` | ||
insection.getIntervals(start, end) => insection.getIntervals('[', start, end, ']'); | ||
insection.getIntervals('[', start, end, ']') => insection.getIntervals(Insection.interval('[', start, end, ']')); | ||
insection.getIntervals('[', start, end, ')') => insection.getIntervals(Insection.interval('[', start, end, ')')); | ||
insection.getIntervals('(', start, end, ']') => insection.getIntervals(Insection.interval('(', start, end, ']')); | ||
insection.getIntervals('(', start, end, ')') => insection.getIntervals(Insection.interval('(', start, end, ')')); | ||
insection.getIntervals('[', start, end, ']') => | ||
insection.getIntervals(Insection.interval('[', start, end, ']')); | ||
insection.getIntervals('[', start, end, ')') => | ||
insection.getIntervals(Insection.interval('[', start, end, ')')); | ||
insection.getIntervals('(', start, end, ']') => | ||
insection.getIntervals(Insection.interval('(', start, end, ']')); | ||
insection.getIntervals('(', start, end, ')') => | ||
insection.getIntervals(Insection.interval('(', start, end, ')')); | ||
insection.getIntervals(interval); | ||
@@ -171,3 +203,7 @@ ``` | ||
expect(insection.getIntervals('(', -Infinity, 2, ')').map(String).sort(), 'to equal', ['[0;4]']); | ||
expect(insection.getIntervals(2).map(String).sort(), 'to equal', ['[0;4]', '[2;Infinity)', '[2;Infinity)']); | ||
expect(insection.getIntervals(2).map(String).sort(), 'to equal', [ | ||
'[0;4]', | ||
'[2;Infinity)', | ||
'[2;Infinity)' | ||
]); | ||
``` | ||
@@ -183,6 +219,10 @@ ### getEntries | ||
insection.getEntries(start, end) => insection.getEntries('[', start, end, ']'); | ||
insection.getEntries('[', start, end, ']') => insection.getEntries(Insection.interval('[', start, end, ']')); | ||
insection.getEntries('[', start, end, ')') => insection.getEntries(Insection.interval('[', start, end, ')')); | ||
insection.getEntries('(', start, end, ']') => insection.getEntries(Insection.interval('(', start, end, ']')); | ||
insection.getEntries('(', start, end, ')') => insection.getEntries(Insection.interval('(', start, end, ')')); | ||
insection.getEntries('[', start, end, ']') => | ||
insection.getEntries(Insection.interval('[', start, end, ']')); | ||
insection.getEntries('[', start, end, ')') => | ||
insection.getEntries(Insection.interval('[', start, end, ')')); | ||
insection.getEntries('(', start, end, ']') => | ||
insection.getEntries(Insection.interval('(', start, end, ']')); | ||
insection.getEntries('(', start, end, ')') => | ||
insection.getEntries(Insection.interval('(', start, end, ')')); | ||
insection.getEntries(interval); | ||
@@ -213,6 +253,10 @@ ``` | ||
insection.contains(start, end) => insection.contains('[', start, end, ']'); | ||
insection.contains('[', start, end, ']') => insection.contains(Insection.interval('[', start, end, ']')); | ||
insection.contains('[', start, end, ')') => insection.contains(Insection.interval('[', start, end, ')')); | ||
insection.contains('(', start, end, ']') => insection.contains(Insection.interval('(', start, end, ']')); | ||
insection.contains('(', start, end, ')') => insection.contains(Insection.interval('(', start, end, ')')); | ||
insection.contains('[', start, end, ']') => | ||
insection.contains(Insection.interval('[', start, end, ']')); | ||
insection.contains('[', start, end, ')') => | ||
insection.contains(Insection.interval('[', start, end, ')')); | ||
insection.contains('(', start, end, ']') => | ||
insection.contains(Insection.interval('(', start, end, ']')); | ||
insection.contains('(', start, end, ')') => | ||
insection.contains(Insection.interval('(', start, end, ')')); | ||
insection.contains(interval); | ||
@@ -244,6 +288,10 @@ ``` | ||
insection.remove(start, end, value) => insection.remove('[', start, end, ']', value); | ||
insection.remove('[', start, end, ']', value) => insection.remove(Insection.interval('[', start, end, ']'), value); | ||
insection.remove('[', start, end, ')', value) => insection.remove(Insection.interval('[', start, end, ')'), value); | ||
insection.remove('(', start, end, ']', value) => insection.remove(Insection.interval('(', start, end, ']'), value); | ||
insection.remove('(', start, end, ')', value) => insection.remove(Insection.interval('(', start, end, ')'), value); | ||
insection.remove('[', start, end, ']', value) => | ||
insection.remove(Insection.interval('[', start, end, ']'), value); | ||
insection.remove('[', start, end, ')', value) => | ||
insection.remove(Insection.interval('[', start, end, ')'), value); | ||
insection.remove('(', start, end, ']', value) => | ||
insection.remove(Insection.interval('(', start, end, ']'), value); | ||
insection.remove('(', start, end, ')', value) => | ||
insection.remove(Insection.interval('(', start, end, ')'), value); | ||
insection.remove(interval, value); | ||
@@ -250,0 +298,0 @@ ``` |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
87001
17
1704
367
2