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

ltgt

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ltgt - npm Package Compare versions

Comparing version 1.0.2 to 1.1.0

83

index.js

@@ -26,13 +26,33 @@

function isDef (val) {
return val != null && val !== ''
return val !== undefined && val !== ''
}
function has (range, name) {
return Object.hasOwnProperty.call(range, name)
}
function hasKey(range, name) {
return Object.hasOwnProperty.call(range, name) && name
}
var lowerBoundKey = exports.lowerBoundKey = function (range) {
return (
hasKey(range, 'gt')
|| hasKey(range, 'gte')
|| hasKey(range, 'min')
|| (range.reverse ? hasKey(range, 'end') : hasKey(range, 'start'))
|| undefined
)
}
var lowerBound = exports.lowerBound = function (range) {
var k = lowerBoundKey(range)
return k && range[k]
return (
isDef(range.gt) ? range.gt
: isDef(range.gte) ? range.gte
: isDef(range.min) ? range.min
: isDef(range.start) && !range.reverse ? range.start
: isDef(range.end) && range.reverse ? range.end
: undefined
has(range, 'gt') ? range.gt
: has(range, 'gte') ? range.gte
: has(range, 'min') ? range.min
: has(range, 'start') && !range.reverse ? range.start
: has(range, 'end') && range.reverse ? range.end
: undefined
)

@@ -42,3 +62,3 @@ }

exports.lowerBoundInclusive = function (range) {
return isDef(range.gt) ? false : true
return has(range, 'gt') ? false : true
}

@@ -48,3 +68,3 @@

function (range) {
return isDef(range.lt) ? false : true
return has(range, 'lt') || !range.minEx ? false : true
}

@@ -54,3 +74,3 @@

function (range) {
return isDef(range.gt) ? true : false
return has(range, 'gt') || range.minEx ? true : false
}

@@ -60,17 +80,42 @@

function (range) {
return isDef(range.lt) ? true : false
return has(range, 'lt') ? true : false
}
var upperBoundKey = exports.upperBoundKey = function (range) {
return (
hasKey(range, 'lt')
|| hasKey(range, 'lte')
|| hasKey(range, 'max')
|| (range.reverse ? hasKey(range, 'start') : hasKey(range, 'end'))
|| undefined
)
}
var upperBound = exports.upperBound = function (range) {
return (
isDef(range.lt) ? range.lt
: isDef(range.lte) ? range.lte
: isDef(range.max) ? range.max
: isDef(range.start) && range.reverse ? range.start
: isDef(range.end) && !range.reverse ? range.end
: undefined
)
var k = upperBoundKey(range)
return k && range[k]
}
function id (e) { return e }
exports.toLtgt = function (range, _range, map) {
_range = _range || {}
map = map || id
var lb = exports.lowerBoundKey(range)
var ub = exports.upperBoundKey(range)
if(lb) {
if(lb === 'gt') _range.gt = map(range.gt)
else _range.gte = map(range[lb])
}
if(ub) {
if(ub === 'lt') _range.lt = map(range.lt)
else _range.lte = map(range[ub])
}
_range.reverse = !!range.reverse
return _range
}
exports.contains = function (range, key, compare) {

@@ -77,0 +122,0 @@ compare = compare || exports.compare

{
"name": "ltgt",
"description": "",
"version": "1.0.2",
"version": "1.1.0",
"homepage": "https://github.com/dominictarr/ltgt",

@@ -6,0 +6,0 @@ "repository": {

@@ -113,4 +113,13 @@ # ltgt

## ltgt.toLtgt(range, _range, map)
convert a range to a new ltgt range. `_range`
is the object to return - if you want to mutate `range`
call `ltgt.toLtgt(range, range, map)`
`map` gets called on each key in the range -
so can be used as an encode function.
## License
MIT

@@ -235,3 +235,13 @@ var tape = require('tape')

actual.reverse()
t.deepEqual(actual, e.selection)
t.deepEqual(actual, e.selection, 'test range:' + JSON.stringify(e.range))
var range = ltgt.toLtgt(e.range)
//should not just return the same thing.
t.notOk(range.min || range.max || range.start || range.end)
var actual2 = elements.filter(ltgt.filter(range))
if(e.range.reverse)
actual2.reverse()
t.deepEqual(actual2, e.selection)
t.end()

@@ -238,0 +248,0 @@ })

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