How to use the gun/gun.text function in gun

To help you get started, we’ve selected a few gun 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 amark / gun / lib / time.js View on Github external
if(data instanceof Function){
			return travel(data, a, b, this);
		}
		var gun = this, root = gun.back(-1);
		var cb = (a instanceof Function && a) || (b instanceof Function && b);
		if(Gun.is(data)){
			data.get(function(soul){
				if(!soul){
					return cb && cb({err: "Timegraph cannot link `undefined`!"});
				}
				gun.time(Gun.val.link.ify(soul), a, b);
			}, true);
			return gun;
		}
		opt = (cb === a)? b : a;
		opt = Gun.text.is(opt)? {key: opt} : opt || {};
		var t = new Date(Gun.state()).toISOString().split(/[\-t\:\.z]/ig);
		var p, tmp = t.pop();
		gun.get(function(soul){
			var id = soul;
			p = id;
			if(!p){ id = p = (gun.back('opt.uuid') || Gun.text.random)(9) }
			// could shrink this into a loop. Do later?
			t = [p].concat(t);
			var rid = opt.key || (gun.back('opt.uuid') || Gun.text.random)(9);
			var milli = ify({}, t.join(':'));
			milli[rid] = data;
			tmp = t.pop();
			var sec = ify({}, t.join(':'));
			sec[tmp] = milli;
			tmp = t.pop();
			var min = ify({}, t.join(':'));
github gundb / gun-rtc / src / local.js View on Github external
/*jslint node: true*/
var Gun = require('gun/gun');
var Emitter = require('events');

// local data interface
window.local = module.exports = {
	db: new Gun({
		rtc: false
	}),

	ID: Gun.text.random(),
	events: new Emitter()
};
github amark / gun / lib / time.js View on Github external
gun.get(function(soul){
			var id = soul;
			p = id;
			if(!p){ id = p = (gun.back('opt.uuid') || Gun.text.random)(9) }
			// could shrink this into a loop. Do later?
			t = [p].concat(t);
			var rid = opt.key || (gun.back('opt.uuid') || Gun.text.random)(9);
			var milli = ify({}, t.join(':'));
			milli[rid] = data;
			tmp = t.pop();
			var sec = ify({}, t.join(':'));
			sec[tmp] = milli;
			tmp = t.pop();
			var min = ify({}, t.join(':'));
			min[tmp] = sec;
			tmp = t.pop();
			var hour = ify({}, t.join(':'));
			hour[tmp] = min;
			tmp = t.pop();
			var day = ify({}, t.join(':'));
github gundb / gun-rtc / lib / greet.js View on Github external
function handleSignal(signal) {
      var obj, SDO = JSON.stringify(signal);
			obj = {};

      filter(SDO);

			// post the session object
			obj[Gun.text.random(10)] = SDO;
      peer.path(myID).put(obj);
		}
github gundb / gun-rtc / src / get.js View on Github external
module.exports = function (lex, cb, opt) {
	opt = {};
	var requestID = Gun.text.random(20);

	local.db.__.opt.wire.get(lex, cb, opt);

	// when calling `.put`, the raw `.get` driver responds
	// with more data causing it to infinitely recurse.
	// support options for server stuns.
	emitter.on(requestID, function (data) {
		cb(data.err, data.value);
	});

	// be more verbose until we have
	// Gun.is.lex, cuz I'm lazy :P
	peers.online.broadcast({
		RID: requestID,
		event: 'get',
		lex: lex,
github sjones6 / gun-flint / bin / commands / gun / examples / angular / src / app / app.component.ts View on Github external
add() {
    if (this.newTodo) {
      this.todos.get(Gun.text.random()).put(this.newTodo);
      this.newTodo = '';
    }
  }
github gundb / gun-rtc / lib / listen.js View on Github external
function handleSignal(signal) {
      var SDO = JSON.stringify(signal);
      filter(SDO);
      requests.path(Gun.text.random(10)).put(SDO);
    }
github amark / gun / examples / angular / src / app / app.component.ts View on Github external
add() {
    if (this.newTodo) {
      this.todos.path(Gun.text.random()).put(this.newTodo);
      this.newTodo = '';
    }
  }
}
github PsychoLlama / Trace / web / join.js View on Github external
module.exports = function () {
	token = Gun.text.random();
	return waiting.path(token).put(token);
};
github gundb / gun-rtc / src / put.js View on Github external
module.exports = function (graph, cb, opt) {
	opt = {};
	var requestID = Gun.text.random(20);

//	Gun.is.graph(graph, function (node, soul) {
//		var graph = local.db.__.graph;
//		if (!graph[soul]) {
//			graph[soul] = node;
//		}
//	});
//	local.db.__.opt.wire.put(graph, cb, opt);
	
	Gun.is.graph(graph, function (node, soul) {
		local.db.put(node).key(soul);
	});

	events.on(requestID, function (data) {
		cb(data.err, data.value);
	});

gun

A realtime, decentralized, offline-first, graph data synchronization engine.

(Zlib OR MIT OR Apache-2.0)
Latest version published 7 months ago

Package Health Score

72 / 100
Full package analysis