How to use sorted-array-functions - 10 common examples

To help you get started, we’ve selected a few sorted-array-functions examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github node-schedule / node-schedule / lib / schedule.js View on Github external
this.trackInvocation = function(invocation) {
    // add to our invocation list
    sorted.add(pendingInvocations, invocation, sorter);
    return true;
  };
  this.stopTrackingInvocation = function(invocation) {
github davidmarkclements / proffer / lib / load-symbols / index.js View on Github external
)

      // duplicates (names may differ slightly...)
      if (addrn in state.code && state.code[addrn].name.length >= name.length) {
        next()
        return
      }

      state.code[addrn] = {
        name: name,
        lib: lib,
        start: '0x' + addrn.toString(16),
        type: 'CPP'
      }

      sorted.add(state.addresses, addrn)

      next()
    }), (err) => {
      lib[PROCESSED] = true
github davidmarkclements / proffer / lib / core-events / code-move.js View on Github external
const match = state.addresses[ix]
      addr = match - 1
      // code previously cleared:
      if (state.code[match] === undefined) {
        sorted.remove(state.addresses, match)
        continue
      }
      if (match + +state.code[match][SIZE] <= to) continue

      sorted.remove(state.addresses, match)
      state.code[match] = undefined
    }

    entry[START] = toAddr
    state.code[to] = entry
    sorted.add(state.addresses, to)

    cb()
  }
}
github davidmarkclements / proffer / lib / core-events / code-move.js View on Github external
const index = sorted.lte(state.addresses, from)
    if (index === -1) {
      opts.warn(`${event} address ${fromAddr} not found`)
      cb()
      return
    }
    const entry = state.code[state.addresses[index]]
    const edge = to + entry[SIZE]

    sorted.remove(state.addresses, from)
    state.code[from] = undefined

    // clear out entries in what will be the new address range of the moved entry
    var addr = edge - 1
    while (addr >= to) {
      const ix = sorted.lte(state.addresses, addr)
      if (ix === -1) break
      const match = state.addresses[ix]
      addr = match - 1
      // code previously cleared:
      if (state.code[match] === undefined) {
        sorted.remove(state.addresses, match)
        continue
      }
      if (match + +state.code[match][SIZE] <= to) continue

      sorted.remove(state.addresses, match)
      state.code[match] = undefined
    }

    entry[START] = toAddr
    state.code[to] = entry
github davidmarkclements / proffer / lib / core-events / code-move.js View on Github external
return function (row, cb) {
    const [event, fromAddr, toAddr] = row
    const from = parseInt(fromAddr, 16)
    const to = parseInt(toAddr, 16)

    const index = sorted.lte(state.addresses, from)
    if (index === -1) {
      opts.warn(`${event} address ${fromAddr} not found`)
      cb()
      return
    }
    const entry = state.code[state.addresses[index]]
    const edge = to + entry[SIZE]

    sorted.remove(state.addresses, from)
    state.code[from] = undefined

    // clear out entries in what will be the new address range of the moved entry
    var addr = edge - 1
    while (addr >= to) {
      const ix = sorted.lte(state.addresses, addr)
      if (ix === -1) break
github mafintosh / multi-random-access / index.js View on Github external
Storage.prototype._get = function (offset) {
  if (this._last) { // high chance that we'll hit the same at least twice
    if (this._last.start <= offset && this._last.end > offset) return this._last
  }

  var i = sorted.lte(this.stores, {start: offset}, cmp)
  if (i === -1) return null

  var next = this.stores[i]
  if (next.start <= offset && next.end > offset) {
    this._last = next
    return next
  }

  return null
}
github davidmarkclements / proffer / lib / core-events / code-move.js View on Github external
const entry = state.code[state.addresses[index]]
    const edge = to + entry[SIZE]

    sorted.remove(state.addresses, from)
    state.code[from] = undefined

    // clear out entries in what will be the new address range of the moved entry
    var addr = edge - 1
    while (addr >= to) {
      const ix = sorted.lte(state.addresses, addr)
      if (ix === -1) break
      const match = state.addresses[ix]
      addr = match - 1
      // code previously cleared:
      if (state.code[match] === undefined) {
        sorted.remove(state.addresses, match)
        continue
      }
      if (match + +state.code[match][SIZE] <= to) continue

      sorted.remove(state.addresses, match)
      state.code[match] = undefined
    }

    entry[START] = toAddr
    state.code[to] = entry
    sorted.add(state.addresses, to)

    cb()
  }
}
github davidmarkclements / proffer / lib / core-events / code-move.js View on Github external
return function (row, cb) {
    const [event, fromAddr, toAddr] = row
    const from = parseInt(fromAddr, 16)
    const to = parseInt(toAddr, 16)

    const index = sorted.lte(state.addresses, from)
    if (index === -1) {
      opts.warn(`${event} address ${fromAddr} not found`)
      cb()
      return
    }
    const entry = state.code[state.addresses[index]]
    const edge = to + entry[SIZE]

    sorted.remove(state.addresses, from)
    state.code[from] = undefined

    // clear out entries in what will be the new address range of the moved entry
    var addr = edge - 1
    while (addr >= to) {
      const ix = sorted.lte(state.addresses, addr)
      if (ix === -1) break
      const match = state.addresses[ix]
      addr = match - 1
      // code previously cleared:
      if (state.code[match] === undefined) {
        sorted.remove(state.addresses, match)
        continue
      }
      if (match + +state.code[match][SIZE] <= to) continue
github sx1989827 / DOClever / node_modules / node-schedule / lib / schedule.js View on Github external
function scheduleInvocation(invocation) {
  sorted.add(invocations, invocation, sorter);
  prepareNextInvocation();
  var date = invocation.fireDate instanceof CronDate ? invocation.fireDate.toDate() : invocation.fireDate;
  invocation.job.emit('scheduled', date);
}
github ILIAS-eLearning / ILIAS / Modules / Chatroom / chat / node_modules / node-schedule / lib / schedule.js View on Github external
function scheduleInvocation(invocation) {
  sorted.add(invocations, invocation, sorter);
  prepareNextInvocation();
  var date = invocation.fireDate instanceof CronDate ? invocation.fireDate.toDate() : invocation.fireDate;
  invocation.job.emit('scheduled', date);
}

sorted-array-functions

Maintain and search through a sorted array using some low level functions

MIT
Latest version published 4 years ago

Package Health Score

67 / 100
Full package analysis

Similar packages