UNPKG

nimma

Version:

Scalable JSONPath engine.

23 lines (18 loc) 569 B
'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); function inBounds (sandbox, pos, start, end, step) { const value = sandbox.valueAt(-1); const actualStart = start < 0 ? Math.max(0, start + value.length) : Math.min(value.length, start); const actualEnd = end < 0 ? Math.max(0, end + value.length) : Math.min(value.length, end); return ( pos >= actualStart && pos < actualEnd && (step === 1 || (actualEnd - Math.abs(step) > 0 && (pos + start) % step === 0)) ); } exports.default = inBounds;