future-gun

0.1.0 • Public • Published

Future gun

future-gun

Gun.js extensions for Promise based async flow control. Promise methods are prefixed with $ by convention.

Install

npm: npm i -S future-gun (soon)

yarn: yarn add future-gun (soon)

from github: npm i -S kristianmandrup/future-gun

Dependencies

  • gun v. 0.6 or higher
  • chain-gun

Use

Assumes Babel.js or similar transpiler setup

To add all chain methods

import Gun from 'gun/gun'
import future from 'future-gun'
future(Gun)

To control which chain methods to add

import {
  addPromise
} from 'future-gun'
add(Gun, 'fields', 'timed', 'value')

Import individual chain modules

import {
  fields,
  addFields
} from 'future-gun/dist/fields'
addFields(Gun.chain)

Require (Node.js)

Using require

const Gun = require('gun/gun')
require('future-gun')(Gun)

Promise extensions

ES6 Promise or ES7 async/await) are always prefixed with $

  • .$fields(opt) - get fields (ie. property names)
  • .$iterate(opts) - iterate
  • .$mapReduce(options, putCb, opt) - map/reduce
  • .$no(opt) - blocks if no data, see no
  • .$val(opt) - full value (with meta)
  • .$value(opt) - get value (no meta)
  • .$valueAt(path, opt) - get value at the path (no meta)
  • .$put(opt) - put value and wait until done (synced)
  • .$putAt(path, opt) - put value at the path and wait until done (synced)
  • .$recurse(filter) - recursive filter
  • .$timed(opts) - timed recursion

mapReduce

See full mapReduce guide

Contributing

Install dependency modules/packages

npm i

Compile/Build

The project includes a gulpfile configured to use Babel 6. All /src files are compiled to /dist including source maps.

Scripts:

  • start: npm start
  • build: npm run build (ie. compile)
  • watch and start: npm run watch
  • watch and build: npm run watch:b

Run Tests

npm test or simply ava test

License

MIT Kristian Mandrup

Package Sidebar

Install

npm i future-gun

Weekly Downloads

0

Version

0.1.0

License

MIT

Last publish

Collaborators

  • kmandrup