Skip to content

Commit

Permalink
API 0.3 BREAKING CHANGES, TESTS PASSING
Browse files Browse the repository at this point in the history
  • Loading branch information
amark committed Dec 22, 2015
2 parents fe6b82d + 2ed4174 commit 6d15aa1
Show file tree
Hide file tree
Showing 67 changed files with 1,871 additions and 20,313 deletions.
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ GUN is a realtime, decentralized, offline-first, graph database engine.

## Getting Started

For the browser, try out this [tutorial](http://gun.js.org/web/think.html) and then use a [starter template](http://plnkr.co/edit/f1yzn5). This README is for GUN servers.
For the browser, try out this [tutorial](http://gun.js.org/think.html) and then use a [starter template](http://plnkr.co/edit/f1yzn5). This README is for GUN servers.

If you do not have [node](http://nodejs.org/) or [npm](https://www.npmjs.com/), read [this](https://github.com/amark/gun/blob/master/examples/install.sh) first.
Then in your terminal, run:
Expand Down Expand Up @@ -115,14 +115,16 @@ Basically, this tells gun to check `'usernames/marknadal'`, and then return the

---

## YOU
Being lonely is never any fun, especially when programming.
## YOU

[Add your project!](https://github.com/amark/gun/wiki/projects)

Our goal is for GUN to be the easiest database ever,
which means if you ever get stuck on something for longer than 5 minutes,
let us know so we can help you. Your input is invaluable,
as it enables us where to refine GUN. So drop us a line in the [![Gitter](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/amark/gun?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)! Or join the [mail list](https://groups.google.com/forum/#!forum/g-u-n).

Thanks to the following people who have contributed to GUN, via code, issues, or conversation:
Thanks to the following people who have contributed to GUN, via code, issues, or conversation (this list has quickly become tremendously behind! We'll probably turn this into a dedicated wiki page so you can add yourself):

[agborkowski](https://github.com/agborkowski); [alexlafroscia](https://github.com/alexlafroscia); [anubiann00b](https://github.com/anubiann00b); [bromagosa](https://github.com/bromagosa); [coolaj86](https://github.com/coolaj86); [d-oliveros](https://github.com/d-oliveros), [danscan](https://github.com/danscan); **[forrestjt](https://github.com/forrestjt) ([file.js](https://github.com/amark/gun/blob/master/lib/file.js))**; [gedw99](https://github.com/gedw99); [HelloCodeMing](https://github.com/HelloCodeMing); **[JosePedroDias](https://github.com/josepedrodias) (graph visualizer)**; **[jveres](https://github.com/jveres) ([todoMVC](https://github.com/jveres/todomvc) [live demo](http://todos.loqali.com/))**; [ndarilek](https://github.com/ndarilek); [onetom](https://github.com/onetom); [phpnode](https://github.com/phpnode); [PsychoLlama](https://github.com/PsychoLlama); **[RangerMauve](https://github.com/RangerMauve) ([schema](https://github.com/gundb/gun-schema))**; [riston](https://github.com/riston); [rootsical](https://github.com/rootsical); [rrrene](https://github.com/rrrene); [ssr1ram](https://github.com/ssr1ram); [Xe](https://github.com/Xe); [zot](https://github.com/zot);

Expand All @@ -144,7 +146,7 @@ We need help on the following roadmap.
## Ahead
- ~~Realtime push to the browser~~
- ~~Persistence in the browser~~
- Efficient storage engine
- ~~Efficient storage engine~~ [@PsychoLlama](https://github.com/psychollama/gun-level)
- Authorization callbacks
- Security or ACLs
- ~~Schema Validation~~ [@RangerMauve](https://github.com/gundb/gun-schema)
Expand Down
1,556 changes: 748 additions & 808 deletions gun.js

Large diffs are not rendered by default.

31 changes: 26 additions & 5 deletions lib/file.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,30 @@ Gun.on('opt').event(function(gun, opts) {
});
all.keys = all.keys || {};
all.nodes = all.nodes || {};

// queue writes, adapted from https://github.com/toolness/jsondown/blob/master/jsondown.js
var isWriting = false, queuedWrites = [];
function writeFile(cb) {
if(isWriting) return queuedWrites.push(cb);
isWriting = true;
fs.writeFile(opts.file, Gun.text.ify(all), function(err) {
var batch = queuedWrites.splice(0);
isWriting = false;
cb(err);
if(batch.length)
writeFile( function(err) {
batch.forEach( function(cb) { cb(err); } )
});
});
}

gun.opt({hooks: {
get: function get(key, cb, o){
var graph, soul;
if(soul = Gun.is.soul(key)){
if(all.nodes[soul]){
(graph = {})[soul] = all.nodes[soul];
cb(null, graph);
cb(null, graph);
(graph = {})[soul] = Gun.union.pseudo(soul);
cb(null, graph); // end.
}
Expand All @@ -37,14 +54,14 @@ Gun.on('opt').event(function(gun, opts) {
return soul? cb(null, {}) : cb(null, null);
},
put: function(graph, cb, o){
all.nodes = gun.__.graph;
fs.writeFile(opts.file, Gun.text.ify(all), cb);
for (key in gun.__.graph) all.nodes[key]=gun.__.graph[key];
writeFile(cb);
},
key: function(key, soul, cb, o){
var meta = {};
meta[Gun._.soul] = soul = Gun.is.soul(soul) || soul;
((all.keys = all.keys || {})[key] = all.keys[key] || {})[soul] = meta;
fs.writeFile(opts.file, Gun.text.ify(all), cb);
writeFile(cb);
},
all: function(list, opt, cb) {
opt = opt || {};
Expand Down Expand Up @@ -85,4 +102,8 @@ Gun.on('opt').event(function(gun, opts) {
cb = cb || function() {};
cb(null, r);
}
}, 100);
<<<<<<< HEAD
}, 100);
=======
});
>>>>>>> master
Loading

0 comments on commit 6d15aa1

Please sign in to comment.