npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

abstract-iterator

v3.0.1

Published

add the iterator ability to abstract-nosql database.

Downloads

28

Readme

AbstractIterator Build Status npm downloads license

Add the iterator ability to the abstract-nosql database.

  • AbstractIterator(db[, options])

    • db: Provided with the current instance of AbstractNoSql.
    • options object(note: some options depend on the implementation of the Iterator)
      • db: the same with the db argument
      • 'next': the raw key data to ensure the readStream return keys is greater than the key. See 'last' event.
        • note: this will affect the range[gt/gte or lt/lte(reverse)] options.
      • 'filter' (function): to filter data in the stream
        • function filter(key, value) if return:
          • 0(consts.FILTER_INCLUDED): include this item(default)
          • 1(consts.FILTER_EXCLUDED): exclude this item.
          • -1(consts.FILTER_STOPPED): stop stream.
        • note: the filter function argument 'key' and 'value' may be null, it is affected via keys and values of this options.
      • 'range' (string or array): the keys are in the give range as the following format:
        • string:
          • "[a, b]": from a to b. a,b included. this means {gte:'a', lte: 'b'}
          • "(a, b]": from a to b. b included, a excluded. this means {gt:'a', lte:'b'}
          • "[, b)" : from begining to b, begining included, b excluded. this means {lt:'b'}
          • "(, b)" : from begining to b, begining excluded, b excluded. this means {gt:null, lt:'b'}
          • note: this will affect the gt/gte/lt/lte options.
            • "(,)": this is not be allowed. the ending should be a value always.
        • array: the key list to get. eg, ['a', 'b', 'c']
          • gt/gte/lt/lte options will be ignored.
      • 'gt' (greater than), 'gte' (greater than or equal) define the lower bound of the range to be streamed. Only records where the key is greater than (or equal to) this option will be included in the range. When reverse=true the order will be reversed, but the records streamed will be the same.
      • 'lt' (less than), 'lte' (less than or equal) define the higher bound of the range to be streamed. Only key/value pairs where the key is less than (or equal to) this option will be included in the range. When reverse=true the order will be reversed, but the records streamed will be the same.
      • 'start', 'end' legacy ranges - instead use 'gte', 'lte'
      • 'match' (string): use the minmatch to match the specified keys.
        • Note: It will affect the range[gt/gte or lt/lte(reverse)] options maybe.
      • 'limit' (number, default: -1): limit the number of results collected by this stream. This number represents a maximum number of results and may not be reached if you get to the end of the data first. A value of -1 means there is no limit. When reverse=true the highest keys will be returned instead of the lowest keys.
      • 'reverse' (boolean, default: false): a boolean, set true and the stream output will be reversed.
      • 'keys' (boolean, default: true): whether the 'data' event should contain keys. If set to true and 'values' set to false then 'data' events will simply be keys, rather than objects with a 'key' property.
      • 'values' (boolean, default: true): whether the 'data' event should contain values. If set to true and 'keys' set to false then 'data' events will simply be values, rather than objects with a 'value' property.
  • next(callback): get the next key/value in the iterator async.

    • callback(err, key, value)
  • nextSync(): return the next {key, value} object in the iterator.

  • free():

  • freeSync():

  • end([callback]):

    • it's the alias for free method() to keep comaptiable with abstract-leveldown.
  • endSync():

    • it's the alias for freeSync method() to keep comaptiable with abstract-leveldown.

The following internal methods need to be implemented:

Sync methods:

AbstractIterator#_nextSync()

Get the next element of this iterator.

return

  • if any result: return a two elements of array
    • the first is the key, the first element could be null or undefined if options.keys is false
    • the second is the value, the second element could be null or undefined if options.values is false
  • or return false, if no any data yet.

AbstractIterator#_endSync()

end the iterator.

Async methods:

these async methods are optional to be implemented.

AbstractIterator#_next(callback)

AbstractIterator#_end(callback)