2.0.1 • Published 7 years ago

localforage-find v2.0.1

Weekly downloads
13
License
MIT
Repository
github
Last release
7 years ago

localforage-find

Adds find function to localforage.

Install and Setup

Works with localforage 1.2.0 or later.

npm install localforage-find

commonjs

const localforage = require('localforage');
require('localforage-find')(localforage);

es6

import localforage from 'localforage';
import addFind from 'localforage-find';

addFind(localforage);

globals

<script>
  localforageFind(localforage);
</script>

API

localforage.find(criteria)

localforage.find(criteria, limit)

localforage.find(criteria, callback)

localforage.find(criteria, limit, callback)

  • criteria - function that takes (key, value) and returns truthy if value should be in results
  • limit - Optional max length of results, defaults to unlimited
  • callback - Optional function that takes (error, resultsArray)

Returns Promise fulfilled with Array of results. Array ordering is not guaranteed.

Examples

With Promises

const limit = 2;

localforage.find((key, value) => value.score > 20, limit)
  .then(resultsArray => {
    // everything in resultsArray has score > 20
    // resultsArray.length is at most 2
  });

With callbacks

const limit = 2;

localforage.find((key, value) => value.score > 20, limit,
  (err, resultsArray) => {
    // everything in resultsArray has score > 20
    // resultsArray.length is at most 2
  });

License

MIT

2.0.1

7 years ago

2.0.0

9 years ago

1.3.0

9 years ago

1.2.0

9 years ago

1.1.0

9 years ago

1.0.0

9 years ago