🚀 Launch Week Day 4:Introducing the Alert Details Page: A Better Way to Explore Alerts.Learn More →
Socket
Book a DemoInstallSign in
Socket

nanocursor

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nanocursor

Small cursor abstraction

latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

nanocursor

Small cursor abstraction that can seek, go forward, and go backwards.

npm install nanocursor

Usage

const Nanocursor = require('nanocursor')

const cursor = new Nanocursor({
  seek (pos, cb) {
    // should seek to pos
    cb(null)
  },
  next (cb) {
    // read the next item and return it
    cb(null, ...)
  },
  prev (cb) {
    // read the prev item and return it
    cb(null, ...)
  }
})

API

cursor = new Cursor([options])

Make a new cursor. Optionally pass in seek, next, prev as the implementation for the those corresponding calls.

cursor.seek(position, [callback])

Seek the cursor.

cursor._seek(position, callback)

Override this method to add seek logic. Only one _prev, _next, or _seek call will be active at the time.

cursor.next(callback)

Get the next cursor item.

cursor._next(callback)

Override this method to add next logic. Only one _prev, _next, or _seek call will be active at the time.

cursor.prev(callback)

Get the prev cursor item.

cursor._prev(callback)

Override this method to add prev logic. Only one _prev, _next, or _seek call will be active at the time.

License

MIT

FAQs

Package last updated on 03 Feb 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts