Permalink
Browse files

Merge branch 'gh-pages' of github.com:nodeGame/NDDB into gh-pages

  • Loading branch information...
2 parents ab39146 + 58906e7 commit 8f87770805aafd0dc92779c821587bdf2283d251 @shakty shakty committed Mar 2, 2016
Showing with 1,027 additions and 596 deletions.
  1. +265 −140 index.html
  2. +1 −1 params.json
  3. +116 −0 stylesheets/github-light.css
  4. +424 −0 stylesheets/normalize.css
  5. +221 −455 stylesheets/stylesheet.css
View
405 index.html
@@ -1,33 +1,25 @@
-<!doctype html>
-<html>
+<!DOCTYPE html>
+<html lang="en-us">
<head>
- <meta charset="utf-8">
- <meta http-equiv="X-UA-Compatible" content="chrome=1">
+ <meta charset="UTF-8">
<title>Nddb by nodeGame</title>
-
- <link rel="stylesheet" href="stylesheets/styles.css">
- <link rel="stylesheet" href="stylesheets/pygment_trac.css">
- <script src="javascripts/scale.fix.js"></script>
- <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
-
- <!--[if lt IE 9]>
- <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
- <![endif]-->
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <link rel="stylesheet" type="text/css" href="stylesheets/normalize.css" media="screen">
+ <link href='https://fonts.googleapis.com/css?family=Open+Sans:400,700' rel='stylesheet' type='text/css'>
+ <link rel="stylesheet" type="text/css" href="stylesheets/stylesheet.css" media="screen">
+ <link rel="stylesheet" type="text/css" href="stylesheets/github-light.css" media="screen">
</head>
<body>
- <div class="wrapper">
- <header>
- <h1>Nddb</h1>
- <p>Javascript lightweight N-dimensional database</p>
- <p class="view"><a href="https://github.com/nodeGame/NDDB">View the Project on GitHub <small>nodeGame/NDDB</small></a></p>
- <ul>
- <li><a href="https://github.com/nodeGame/NDDB/zipball/master">Download <strong>ZIP File</strong></a></li>
- <li><a href="https://github.com/nodeGame/NDDB/tarball/master">Download <strong>TAR Ball</strong></a></li>
- <li><a href="https://github.com/nodeGame/NDDB">View On <strong>GitHub</strong></a></li>
- </ul>
- </header>
- <section>
- <h1>
+ <section class="page-header">
+ <h1 class="project-name">Nddb</h1>
+ <h2 class="project-tagline">Javascript lightweight N-dimensional database</h2>
+ <a href="https://github.com/nodeGame/NDDB" class="btn">View on GitHub</a>
+ <a href="https://github.com/nodeGame/NDDB/zipball/master" class="btn">Download .zip</a>
+ <a href="https://github.com/nodeGame/NDDB/tarball/master" class="btn">Download .tar.gz</a>
+ </section>
+
+ <section class="main-content">
+ <h1>
<a id="nddb" class="anchor" href="#nddb" aria-hidden="true"><span class="octicon octicon-link"></span></a>NDDB</h1>
<p><a href="https://travis-ci.org/nodeGame/NDDB"><img src="https://travis-ci.org/nodeGame/NDDB.png?branch=master" alt="Build Status"></a></p>
@@ -75,7 +67,7 @@
</li>
<li>Event listener / emitter: <code>on</code>, <code>off</code>, <code>emit</code>
</li>
-<li>Saving and Loading: <code>save</code>, <code>load</code>, <code>loadCSV</code>
+<li>Saving and Loading: <code>save</code>, <code>saveSync</code>, <code>load</code>, <code>loadSync</code>
</li>
</ul>
@@ -87,52 +79,52 @@
<p>Load the library in Node.js:</p>
-<div class="highlight highlight-javascript"><pre><span class="pl-s">var</span> NDDB <span class="pl-k">=</span> <span class="pl-s3">require</span>(<span class="pl-s1"><span class="pl-pds">'</span>NDDB<span class="pl-pds">'</span></span>).NDDB;</pre></div>
+<div class="highlight highlight-source-js"><pre><span class="pl-k">var</span> <span class="pl-c1">NDDB</span> <span class="pl-k">=</span> <span class="pl-c1">require</span>(<span class="pl-s"><span class="pl-pds">'</span>NDDB<span class="pl-pds">'</span></span>).NDDB;</pre></div>
<p>or in the browser add a script tag in the page:</p>
-<div class="highlight highlight-html"><pre><span class="pl-c">&lt;!-- Must load a version of NDDB that includes JSUS (see 'build/' dir) --&gt;</span>
-&lt;<span class="pl-ent">script</span> <span class="pl-e">src</span>=<span class="pl-s1"><span class="pl-pds">"</span>/path/to/nddb.js<span class="pl-pds">"</span></span>&gt;&lt;/<span class="pl-ent">script</span>&gt;</pre></div>
+<div class="highlight highlight-text-html-basic"><pre><span class="pl-c">&lt;!-- Must load a version of NDDB that includes JSUS (see 'build/' dir) --&gt;</span>
+&lt;<span class="pl-ent">script</span> <span class="pl-e">src</span>=<span class="pl-s"><span class="pl-pds">"</span>/path/to/nddb.js<span class="pl-pds">"</span></span>&gt;&lt;/<span class="pl-ent">script</span>&gt;</pre></div>
<p>Create an instance of NDDB:</p>
-<div class="highlight highlight-javascript"><pre><span class="pl-s">var</span> db <span class="pl-k">=</span> <span class="pl-k">new</span> <span class="pl-en">NDDB</span>();</pre></div>
+<div class="highlight highlight-source-js"><pre><span class="pl-k">var</span> db <span class="pl-k">=</span> <span class="pl-k">new</span> <span class="pl-en">NDDB</span>();</pre></div>
<p>Insert an item into the database:</p>
-<div class="highlight highlight-javascript"><pre>db.insert({
- painter<span class="pl-k">:</span> <span class="pl-s1"><span class="pl-pds">"</span>Picasso<span class="pl-pds">"</span></span>,
- title<span class="pl-k">:</span> <span class="pl-s1"><span class="pl-pds">"</span>Les Demoiselles d'Avignon<span class="pl-pds">"</span></span>,
+<div class="highlight highlight-source-js"><pre>db.insert({
+ painter<span class="pl-k">:</span> <span class="pl-s"><span class="pl-pds">"</span>Picasso<span class="pl-pds">"</span></span>,
+ title<span class="pl-k">:</span> <span class="pl-s"><span class="pl-pds">"</span>Les Demoiselles d'Avignon<span class="pl-pds">"</span></span>,
year<span class="pl-k">:</span> <span class="pl-c1">1907</span>
});</pre></div>
<p>Import a collection of items:</p>
-<div class="highlight highlight-javascript"><pre><span class="pl-s">var</span> items <span class="pl-k">=</span> [
+<div class="highlight highlight-source-js"><pre><span class="pl-k">var</span> items <span class="pl-k">=</span> [
{
- painter<span class="pl-k">:</span> <span class="pl-s1"><span class="pl-pds">"</span>Dali<span class="pl-pds">"</span></span>,
- title<span class="pl-k">:</span> <span class="pl-s1"><span class="pl-pds">"</span>Portrait of Paul Eluard<span class="pl-pds">"</span></span>,
+ painter<span class="pl-k">:</span> <span class="pl-s"><span class="pl-pds">"</span>Dali<span class="pl-pds">"</span></span>,
+ title<span class="pl-k">:</span> <span class="pl-s"><span class="pl-pds">"</span>Portrait of Paul Eluard<span class="pl-pds">"</span></span>,
year<span class="pl-k">:</span> <span class="pl-c1">1929</span>,
portrait<span class="pl-k">:</span> <span class="pl-c1">true</span>
},
{
- painter<span class="pl-k">:</span> <span class="pl-s1"><span class="pl-pds">"</span>Dali<span class="pl-pds">"</span></span>,
- title<span class="pl-k">:</span> <span class="pl-s1"><span class="pl-pds">"</span>Barcelonese Mannequin<span class="pl-pds">"</span></span>,
+ painter<span class="pl-k">:</span> <span class="pl-s"><span class="pl-pds">"</span>Dali<span class="pl-pds">"</span></span>,
+ title<span class="pl-k">:</span> <span class="pl-s"><span class="pl-pds">"</span>Barcelonese Mannequin<span class="pl-pds">"</span></span>,
year<span class="pl-k">:</span> <span class="pl-c1">1927</span>
},
{
- painter<span class="pl-k">:</span> <span class="pl-s1"><span class="pl-pds">"</span>Monet<span class="pl-pds">"</span></span>,
- title<span class="pl-k">:</span> <span class="pl-s1"><span class="pl-pds">"</span>Water Lilies<span class="pl-pds">"</span></span>,
+ painter<span class="pl-k">:</span> <span class="pl-s"><span class="pl-pds">"</span>Monet<span class="pl-pds">"</span></span>,
+ title<span class="pl-k">:</span> <span class="pl-s"><span class="pl-pds">"</span>Water Lilies<span class="pl-pds">"</span></span>,
year<span class="pl-k">:</span> <span class="pl-c1">1906</span>
},
{
- painter<span class="pl-k">:</span> <span class="pl-s1"><span class="pl-pds">"</span>Monet<span class="pl-pds">"</span></span>,
- title<span class="pl-k">:</span> <span class="pl-s1"><span class="pl-pds">"</span>Wheatstacks (End of Summer)<span class="pl-pds">"</span></span>,
+ painter<span class="pl-k">:</span> <span class="pl-s"><span class="pl-pds">"</span>Monet<span class="pl-pds">"</span></span>,
+ title<span class="pl-k">:</span> <span class="pl-s"><span class="pl-pds">"</span>Wheatstacks (End of Summer)<span class="pl-pds">"</span></span>,
year<span class="pl-k">:</span> <span class="pl-c1">1891</span>
},
{
- painter<span class="pl-k">:</span> <span class="pl-s1"><span class="pl-pds">"</span>Manet<span class="pl-pds">"</span></span>,
- title<span class="pl-k">:</span> <span class="pl-s1"><span class="pl-pds">"</span>Olympia<span class="pl-pds">"</span></span>,
+ painter<span class="pl-k">:</span> <span class="pl-s"><span class="pl-pds">"</span>Manet<span class="pl-pds">"</span></span>,
+ title<span class="pl-k">:</span> <span class="pl-s"><span class="pl-pds">"</span>Olympia<span class="pl-pds">"</span></span>,
year<span class="pl-k">:</span> <span class="pl-c1">1863</span>
}
];
@@ -141,14 +133,14 @@
<p>Retrieve the database size:</p>
-<div class="highlight highlight-javascript"><pre><span class="pl-s">var</span> db_size <span class="pl-k">=</span> db.<span class="pl-sc">size</span>(); <span class="pl-c">// 6</span></pre></div>
+<div class="highlight highlight-source-js"><pre><span class="pl-k">var</span> db_size <span class="pl-k">=</span> db.<span class="pl-c1">size</span>(); <span class="pl-c">// 6</span></pre></div>
<h3>
<a id="select-items" class="anchor" href="#select-items" aria-hidden="true"><span class="octicon octicon-link"></span></a>Select Items</h3>
<p>Select statements must begin with <code>select</code>, and can be concatened by
any number of subsequent <code>and</code> and <code>or</code> statements. The comparison in
-select statements is performed using three input parameters: </p>
+select statements is performed using three input parameters:</p>
<ul>
<li>'property'</li>
@@ -160,7 +152,7 @@
<ul>
<li>
-<code>=</code>, <code>==</code>, <code>!=</code>, `<code>&gt;</code>, &gt;=<code>,</code>&lt;<code>,</code>&lt;=`,</li>
+<code>=</code>, <code>==</code>, <code>!=</code>, <code>&gt;</code>, &gt;=<code>,</code>&lt;<code>,</code>&lt;=`,</li>
</ul>
<p>or advanced comparison operators:</p>
@@ -193,36 +185,36 @@
<p>Select all paintings from Dali:</p>
-<div class="highlight highlight-javascript"><pre>db.<span class="pl-s3">select</span>(<span class="pl-s1"><span class="pl-pds">'</span>painter<span class="pl-pds">'</span></span>, <span class="pl-s1"><span class="pl-pds">'</span>=<span class="pl-pds">'</span></span>, <span class="pl-s1"><span class="pl-pds">'</span>Dali<span class="pl-pds">'</span></span>); <span class="pl-c">// 2 items</span></pre></div>
+<div class="highlight highlight-source-js"><pre>db.<span class="pl-c1">select</span>(<span class="pl-s"><span class="pl-pds">'</span>painter<span class="pl-pds">'</span></span>, <span class="pl-s"><span class="pl-pds">'</span>=<span class="pl-pds">'</span></span>, <span class="pl-s"><span class="pl-pds">'</span>Dali<span class="pl-pds">'</span></span>); <span class="pl-c">// 2 items</span></pre></div>
<p>Case sensitive <code>LIKE</code> operator:</p>
-<div class="highlight highlight-javascript"><pre>db.<span class="pl-s3">select</span>(<span class="pl-s1"><span class="pl-pds">'</span>painter<span class="pl-pds">'</span></span>, <span class="pl-s1"><span class="pl-pds">'</span>LIKE<span class="pl-pds">'</span></span>, <span class="pl-s1"><span class="pl-pds">'</span>M_net<span class="pl-pds">'</span></span>); <span class="pl-c">// 3 items</span></pre></div>
+<div class="highlight highlight-source-js"><pre>db.<span class="pl-c1">select</span>(<span class="pl-s"><span class="pl-pds">'</span>painter<span class="pl-pds">'</span></span>, <span class="pl-s"><span class="pl-pds">'</span>LIKE<span class="pl-pds">'</span></span>, <span class="pl-s"><span class="pl-pds">'</span>M_net<span class="pl-pds">'</span></span>); <span class="pl-c">// 3 items</span></pre></div>
<p>Select on multiple properties (<code>*</code>) with case insensitive <code>LIKE</code>:</p>
-<div class="highlight highlight-javascript"><pre>db.<span class="pl-s3">select</span>(<span class="pl-s1"><span class="pl-pds">'</span>*<span class="pl-pds">'</span></span>, <span class="pl-s1"><span class="pl-pds">'</span>iLIKE<span class="pl-pds">'</span></span>, <span class="pl-s1"><span class="pl-pds">'</span>%e%<span class="pl-pds">'</span></span>); <span class="pl-c">// All items</span>
-db.<span class="pl-s3">select</span>([<span class="pl-s1"><span class="pl-pds">'</span>painter<span class="pl-pds">'</span></span>, <span class="pl-s1"><span class="pl-pds">'</span>portrait<span class="pl-pds">'</span></span>], <span class="pl-s1"><span class="pl-pds">'</span>iLIKE<span class="pl-pds">'</span></span>, <span class="pl-s1"><span class="pl-pds">'</span>%e%<span class="pl-pds">'</span></span>) <span class="pl-c">// 5 items</span></pre></div>
+<div class="highlight highlight-source-js"><pre>db.<span class="pl-c1">select</span>(<span class="pl-s"><span class="pl-pds">'</span>*<span class="pl-pds">'</span></span>, <span class="pl-s"><span class="pl-pds">'</span>iLIKE<span class="pl-pds">'</span></span>, <span class="pl-s"><span class="pl-pds">'</span>%e%<span class="pl-pds">'</span></span>); <span class="pl-c">// All items</span>
+db.<span class="pl-c1">select</span>([<span class="pl-s"><span class="pl-pds">'</span>painter<span class="pl-pds">'</span></span>, <span class="pl-s"><span class="pl-pds">'</span>portrait<span class="pl-pds">'</span></span>], <span class="pl-s"><span class="pl-pds">'</span>iLIKE<span class="pl-pds">'</span></span>, <span class="pl-s"><span class="pl-pds">'</span>%e%<span class="pl-pds">'</span></span>) <span class="pl-c">// 5 items</span></pre></div>
<p>Select all portraits:</p>
-<div class="highlight highlight-javascript"><pre>db.<span class="pl-s3">select</span>(<span class="pl-s1"><span class="pl-pds">'</span>portrait<span class="pl-pds">'</span></span>); <span class="pl-c">// 1 item</span></pre></div>
+<div class="highlight highlight-source-js"><pre>db.<span class="pl-c1">select</span>(<span class="pl-s"><span class="pl-pds">'</span>portrait<span class="pl-pds">'</span></span>); <span class="pl-c">// 1 item</span></pre></div>
<p>Fetch all paintings from Dali that are before 1928:</p>
-<div class="highlight highlight-javascript"><pre>db.<span class="pl-s3">select</span>(<span class="pl-s1"><span class="pl-pds">'</span>painter<span class="pl-pds">'</span></span>, <span class="pl-s1"><span class="pl-pds">'</span>=<span class="pl-pds">'</span></span>, <span class="pl-s1"><span class="pl-pds">'</span>Dali<span class="pl-pds">'</span></span>)
- .and(<span class="pl-s1"><span class="pl-pds">'</span>year<span class="pl-pds">'</span></span>, <span class="pl-s1"><span class="pl-pds">'</span>&lt;<span class="pl-pds">'</span></span>, <span class="pl-c1">1928</span>);
+<div class="highlight highlight-source-js"><pre>db.<span class="pl-c1">select</span>(<span class="pl-s"><span class="pl-pds">'</span>painter<span class="pl-pds">'</span></span>, <span class="pl-s"><span class="pl-pds">'</span>=<span class="pl-pds">'</span></span>, <span class="pl-s"><span class="pl-pds">'</span>Dali<span class="pl-pds">'</span></span>)
+ .and(<span class="pl-s"><span class="pl-pds">'</span>year<span class="pl-pds">'</span></span>, <span class="pl-s"><span class="pl-pds">'</span>&lt;<span class="pl-pds">'</span></span>, <span class="pl-c1">1928</span>);
.fetch(); <span class="pl-c">// 1 item</span></pre></div>
<p>Fetch all paintings of the beginning of XX's century:</p>
-<div class="highlight highlight-javascript"><pre> db.<span class="pl-s3">select</span>(<span class="pl-s1"><span class="pl-pds">'</span>year<span class="pl-pds">'</span></span>, <span class="pl-s1"><span class="pl-pds">'</span>&gt;&lt;<span class="pl-pds">'</span></span>, [<span class="pl-c1">1900</span>, <span class="pl-c1">1910</span>])
+<div class="highlight highlight-source-js"><pre> db.<span class="pl-c1">select</span>(<span class="pl-s"><span class="pl-pds">'</span>year<span class="pl-pds">'</span></span>, <span class="pl-s"><span class="pl-pds">'</span>&gt;&lt;<span class="pl-pds">'</span></span>, [<span class="pl-c1">1900</span>, <span class="pl-c1">1910</span>])
.fetch(); <span class="pl-c">// 2 items</span></pre></div>
<p>Fetch separately all the painters and all the dates of the paintings:</p>
-<div class="highlight highlight-javascript"><pre>db.<span class="pl-s3">select</span>(<span class="pl-s1"><span class="pl-pds">'</span>year<span class="pl-pds">'</span></span>, <span class="pl-s1"><span class="pl-pds">'</span>&gt;&lt;<span class="pl-pds">'</span></span>, [<span class="pl-c1">1900</span>, <span class="pl-c1">1910</span>])
- .fetchValues([<span class="pl-s1"><span class="pl-pds">'</span>painter<span class="pl-pds">'</span></span>, <span class="pl-s1"><span class="pl-pds">'</span>title<span class="pl-pds">'</span></span>]);
+<div class="highlight highlight-source-js"><pre>db.<span class="pl-c1">select</span>(<span class="pl-s"><span class="pl-pds">'</span>year<span class="pl-pds">'</span></span>, <span class="pl-s"><span class="pl-pds">'</span>&gt;&lt;<span class="pl-pds">'</span></span>, [<span class="pl-c1">1900</span>, <span class="pl-c1">1910</span>])
+ .fetchValues([<span class="pl-s"><span class="pl-pds">'</span>painter<span class="pl-pds">'</span></span>, <span class="pl-s"><span class="pl-pds">'</span>title<span class="pl-pds">'</span></span>]);
<span class="pl-c">// { painter: [ 'Jesus', 'Dali', 'Dali', 'Monet', 'Monet', 'Manet' ],</span>
<span class="pl-c">// year: [ 0, 1929, 1927, 1906, 1891, 1863 ] }</span></pre></div>
@@ -232,85 +224,85 @@
<p>Define a global comparator function that sorts all the entries chronologically:</p>
-<div class="highlight highlight-javascript"><pre><span class="pl-s3">db</span>.<span class="pl-en">globalCompator</span> <span class="pl-k">=</span> <span class="pl-st">function</span> (<span class="pl-vpf">o1</span>, <span class="pl-vpf">o2</span>) {
+<div class="highlight highlight-source-js"><pre><span class="pl-c1">db</span>.<span class="pl-en">globalCompator</span> <span class="pl-k">=</span> <span class="pl-k">function</span> (<span class="pl-smi">o1</span>, <span class="pl-smi">o2</span>) {
<span class="pl-k">if</span> (o1.year <span class="pl-k">&lt;</span> o2.year) <span class="pl-k">return</span> <span class="pl-c1">1</span>;
<span class="pl-k">if</span> (o1.year <span class="pl-k">&lt;</span> o2.year) <span class="pl-k">return</span> <span class="pl-c1">2</span>;
<span class="pl-k">return</span> <span class="pl-c1">0</span>;
};</pre></div>
<p>Sort all the items (global comparator function is automatically used):</p>
-<div class="highlight highlight-javascript"><pre>db.<span class="pl-s3">sort</span>(); <span class="pl-c">// Order: Manet, Monet, Monet, Picasso, Dali, Dali</span></pre></div>
+<div class="highlight highlight-source-js"><pre>db.<span class="pl-c1">sort</span>(); <span class="pl-c">// Order: Manet, Monet, Monet, Picasso, Dali, Dali</span></pre></div>
<p>Reverse the order of the items:</p>
-<div class="highlight highlight-javascript"><pre>db.<span class="pl-s3">reverse</span>(); <span class="pl-c">// Order: Dali, Dali, Picasso, Monet, Monet, Manet</span></pre></div>
+<div class="highlight highlight-source-js"><pre>db.<span class="pl-c1">reverse</span>(); <span class="pl-c">// Order: Dali, Dali, Picasso, Monet, Monet, Manet</span></pre></div>
<p>Define a custom comparator function for the name of the painter, which
gives highest priorities to the canvases of Picasso;</p>
-<div class="highlight highlight-javascript"><pre>db.compare(<span class="pl-s1"><span class="pl-pds">'</span>painter<span class="pl-pds">'</span></span>, <span class="pl-st">function</span> (<span class="pl-vpf">o1</span>, <span class="pl-vpf">o2</span>) {
- <span class="pl-k">if</span> (o1.painter <span class="pl-k">===</span> <span class="pl-s1"><span class="pl-pds">'</span>Picasso<span class="pl-pds">'</span></span>) <span class="pl-k">return</span> <span class="pl-k">-</span><span class="pl-c1">1</span>;
- <span class="pl-k">if</span> (o2.painter <span class="pl-k">===</span> <span class="pl-s1"><span class="pl-pds">'</span>Picasso<span class="pl-pds">'</span></span>) <span class="pl-k">return</span> <span class="pl-c1">1</span>;
+<div class="highlight highlight-source-js"><pre>db.compare(<span class="pl-s"><span class="pl-pds">'</span>painter<span class="pl-pds">'</span></span>, <span class="pl-k">function</span> (<span class="pl-smi">o1</span>, <span class="pl-smi">o2</span>) {
+ <span class="pl-k">if</span> (o1.painter <span class="pl-k">===</span> <span class="pl-s"><span class="pl-pds">'</span>Picasso<span class="pl-pds">'</span></span>) <span class="pl-k">return</span> <span class="pl-k">-</span><span class="pl-c1">1</span>;
+ <span class="pl-k">if</span> (o2.painter <span class="pl-k">===</span> <span class="pl-s"><span class="pl-pds">'</span>Picasso<span class="pl-pds">'</span></span>) <span class="pl-k">return</span> <span class="pl-c1">1</span>;
}</pre></div>
<p>Sort all the paintings by painter</p>
-<div class="highlight highlight-javascript"><pre>db.<span class="pl-s3">sort</span>(<span class="pl-s1"><span class="pl-pds">'</span>painter<span class="pl-pds">'</span></span>); <span class="pl-c">// Picasso is always listed first</span></pre></div>
+<div class="highlight highlight-source-js"><pre>db.<span class="pl-c1">sort</span>(<span class="pl-s"><span class="pl-pds">'</span>painter<span class="pl-pds">'</span></span>); <span class="pl-c">// Picasso is always listed first</span></pre></div>
<h3>
<a id="views" class="anchor" href="#views" aria-hidden="true"><span class="octicon octicon-link"></span></a>Views</h3>
<p>Splits the database in sub-database, each containing semantically
consistent set of entries:</p>
-<div class="highlight highlight-javascript"><pre><span class="pl-c">// Let us add some cars to our previous database of paintings.</span>
-<span class="pl-s">var</span> not_art_items <span class="pl-k">=</span> [
+<div class="highlight highlight-source-js"><pre><span class="pl-c">// Let us add some cars to our previous database of paintings.</span>
+<span class="pl-k">var</span> not_art_items <span class="pl-k">=</span> [
{
- car<span class="pl-k">:</span> <span class="pl-s1"><span class="pl-pds">"</span>Ferrari<span class="pl-pds">"</span></span>,
- model<span class="pl-k">:</span> <span class="pl-s1"><span class="pl-pds">"</span>F10<span class="pl-pds">"</span></span>,
+ car<span class="pl-k">:</span> <span class="pl-s"><span class="pl-pds">"</span>Ferrari<span class="pl-pds">"</span></span>,
+ model<span class="pl-k">:</span> <span class="pl-s"><span class="pl-pds">"</span>F10<span class="pl-pds">"</span></span>,
speed<span class="pl-k">:</span> <span class="pl-c1">350</span>,
},
{
- car<span class="pl-k">:</span> <span class="pl-s1"><span class="pl-pds">"</span>Fiat<span class="pl-pds">"</span></span>,
- model<span class="pl-k">:</span> <span class="pl-s1"><span class="pl-pds">"</span>500<span class="pl-pds">"</span></span>,
+ car<span class="pl-k">:</span> <span class="pl-s"><span class="pl-pds">"</span>Fiat<span class="pl-pds">"</span></span>,
+ model<span class="pl-k">:</span> <span class="pl-s"><span class="pl-pds">"</span>500<span class="pl-pds">"</span></span>,
speed<span class="pl-k">:</span> <span class="pl-c1">100</span>,
},
{
- car<span class="pl-k">:</span> <span class="pl-s1"><span class="pl-pds">"</span>BMW<span class="pl-pds">"</span></span>,
- model<span class="pl-k">:</span> <span class="pl-s1"><span class="pl-pds">"</span>Z4<span class="pl-pds">"</span></span>,
+ car<span class="pl-k">:</span> <span class="pl-s"><span class="pl-pds">"</span>BMW<span class="pl-pds">"</span></span>,
+ model<span class="pl-k">:</span> <span class="pl-s"><span class="pl-pds">"</span>Z4<span class="pl-pds">"</span></span>,
speed<span class="pl-k">:</span> <span class="pl-c1">250</span>,
},
];
-db.view(<span class="pl-s1"><span class="pl-pds">'</span>art<span class="pl-pds">'</span></span>, <span class="pl-st">function</span>(<span class="pl-vpf">o</span>) {
+db.view(<span class="pl-s"><span class="pl-pds">'</span>art<span class="pl-pds">'</span></span>, <span class="pl-k">function</span>(<span class="pl-smi">o</span>) {
<span class="pl-k">return</span> o.painter;
});
-db.view(<span class="pl-s1"><span class="pl-pds">'</span>cars<span class="pl-pds">'</span></span>, <span class="pl-st">function</span>(<span class="pl-vpf">o</span>) {
+db.view(<span class="pl-s"><span class="pl-pds">'</span>cars<span class="pl-pds">'</span></span>, <span class="pl-k">function</span>(<span class="pl-smi">o</span>) {
<span class="pl-k">return</span> o.car;
});
db.rebuildIndexes();
-db.<span class="pl-sc">size</span>(); <span class="pl-c">// 9</span>
-db.art.<span class="pl-sc">size</span>(); <span class="pl-c">// NDDB with 6 art entries</span>
-db.cars.<span class="pl-sc">size</span>(); <span class="pl-c">// NDDB with 3 car entries</span></pre></div>
+db.<span class="pl-c1">size</span>(); <span class="pl-c">// 9</span>
+db.art.<span class="pl-c1">size</span>(); <span class="pl-c">// NDDB with 6 art entries</span>
+db.cars.<span class="pl-c1">size</span>(); <span class="pl-c">// NDDB with 3 car entries</span></pre></div>
<h3>
<a id="hashing" class="anchor" href="#hashing" aria-hidden="true"><span class="octicon octicon-link"></span></a>Hashing</h3>
<p>Define a custom hash function that creates a new view on each of the
painters in the database:</p>
-<div class="highlight highlight-javascript"><pre>db.<span class="pl-sc">hash</span>(<span class="pl-s1"><span class="pl-pds">'</span>painter<span class="pl-pds">'</span></span>, <span class="pl-st">function</span>(<span class="pl-vpf">o</span>) {
+<div class="highlight highlight-source-js"><pre>db.<span class="pl-c1">hash</span>(<span class="pl-s"><span class="pl-pds">'</span>painter<span class="pl-pds">'</span></span>, <span class="pl-k">function</span>(<span class="pl-smi">o</span>) {
<span class="pl-k">if</span> (<span class="pl-k">!</span>o) <span class="pl-k">return</span> <span class="pl-c1">undefined</span>;
<span class="pl-k">return</span> o.painter;
});
db.rebuildIndexes();
-db.<span class="pl-sc">size</span>(); <span class="pl-c">// 6, unchanged;</span>
+db.<span class="pl-c1">size</span>(); <span class="pl-c">// 6, unchanged;</span>
db.painter.Picasso; <span class="pl-c">// NDDB with 1 element in db</span>
db.painter.Monet <span class="pl-c">// NDDB with 2 elements in db</span>
db.painter.Manet <span class="pl-c">// NDDB with 1 elements in db</span>
@@ -322,11 +314,11 @@
<p>Listen to the <code>insert</code> event and modify the inserted items by adding
an external index to them:</p>
-<div class="highlight highlight-javascript"><pre><span class="pl-s">var</span> id <span class="pl-k">=</span> <span class="pl-c1">0</span>;
-<span class="pl-st">function</span> <span class="pl-en">getMyId</span>(){ <span class="pl-k">return</span> id<span class="pl-k">++</span>; };
+<div class="highlight highlight-source-js"><pre><span class="pl-k">var</span> id <span class="pl-k">=</span> <span class="pl-c1">0</span>;
+<span class="pl-k">function</span> <span class="pl-en">getMyId</span>(){ <span class="pl-k">return</span> id<span class="pl-k">++</span>; };
-db.on(<span class="pl-s1"><span class="pl-pds">'</span>insert<span class="pl-pds">'</span></span>, <span class="pl-st">function</span>(<span class="pl-vpf">o</span>) {
- o.painter.<span class="pl-sc">id</span> <span class="pl-k">=</span> getMyId();
+db.on(<span class="pl-s"><span class="pl-pds">'</span>insert<span class="pl-pds">'</span></span>, <span class="pl-k">function</span>(<span class="pl-smi">o</span>) {
+ o.painter.<span class="pl-c1">id</span> <span class="pl-k">=</span> getMyId();
});</pre></div>
<h3>
@@ -335,23 +327,23 @@
<p>Define a custom indexing function that gives fast, direct access to
the items of the database;</p>
-<div class="highlight highlight-javascript"><pre>db.<span class="pl-sc">index</span>(<span class="pl-s1"><span class="pl-pds">'</span>pid<span class="pl-pds">'</span></span>, <span class="pl-st">function</span>(<span class="pl-vpf">o</span>) {
- <span class="pl-k">return</span> o.<span class="pl-sc">id</span>;
+<div class="highlight highlight-source-js"><pre>db.<span class="pl-c1">index</span>(<span class="pl-s"><span class="pl-pds">'</span>pid<span class="pl-pds">'</span></span>, <span class="pl-k">function</span>(<span class="pl-smi">o</span>) {
+ <span class="pl-k">return</span> o.<span class="pl-c1">id</span>;
});
db.rebuildIndexes();
-db.pid.get(<span class="pl-c1">0</span>).<span class="pl-sc">name</span>; <span class="pl-c">// Picasso</span>
+db.pid.get(<span class="pl-c1">0</span>).<span class="pl-c1">name</span>; <span class="pl-c">// Picasso</span>
db.pid.update(<span class="pl-c1">0</span>, {
- comment<span class="pl-k">:</span> <span class="pl-s1"><span class="pl-pds">"</span>Good job Pablo!<span class="pl-pds">"</span></span>
+ comment<span class="pl-k">:</span> <span class="pl-s"><span class="pl-pds">"</span>Good job Pablo!<span class="pl-pds">"</span></span>
});
<span class="pl-c">// Counts items in selection.</span>
-db.<span class="pl-s3">select</span>(<span class="pl-s1"><span class="pl-pds">'</span>comment<span class="pl-pds">'</span></span>).count(); <span class="pl-c">// 1</span>
+db.<span class="pl-c1">select</span>(<span class="pl-s"><span class="pl-pds">'</span>comment<span class="pl-pds">'</span></span>).count(); <span class="pl-c">// 1</span>
-<span class="pl-s">var</span> picasso <span class="pl-k">=</span> db.pid.<span class="pl-s3">remove</span>(<span class="pl-c1">0</span>);
-db.<span class="pl-sc">size</span>(); <span class="pl-c">// (0)</span>
+<span class="pl-k">var</span> picasso <span class="pl-k">=</span> db.pid.remove(<span class="pl-c1">0</span>);
+db.<span class="pl-c1">size</span>(); <span class="pl-c">// (0)</span>
<span class="pl-c">// Get all available keys in the index</span>
db.painter.getAllKeys(); <span class="pl-c">// ['0','1', ... ]</span>
@@ -362,13 +354,13 @@
<h2>
<a id="example-of-a-configuration-object" class="anchor" href="#example-of-a-configuration-object" aria-hidden="true"><span class="octicon octicon-link"></span></a>Example of a configuration object</h2>
-<div class="highlight highlight-javascript"><pre><span class="pl-s">var</span> <span class="pl-en">logFunc</span> <span class="pl-k">=</span> <span class="pl-st">function</span>(<span class="pl-vpf">txt</span>, <span class="pl-vpf">level</span>) {
+<div class="highlight highlight-source-js"><pre><span class="pl-k">var</span> <span class="pl-en">logFunc</span> <span class="pl-k">=</span> <span class="pl-k">function</span>(<span class="pl-smi">txt</span>, <span class="pl-smi">level</span>) {
<span class="pl-k">if</span> (level <span class="pl-k">&gt;</span> <span class="pl-c1">0</span>) {
- <span class="pl-en">console</span><span class="pl-s3">.log</span>(txt);
+ <span class="pl-en">console</span>.<span class="pl-c1">log</span>(txt);
}
};
-<span class="pl-s">var</span> options <span class="pl-k">=</span> {
+<span class="pl-k">var</span> options <span class="pl-k">=</span> {
tags<span class="pl-k">:</span> {}, <span class="pl-c">// Collection of tags</span>
update<span class="pl-k">:</span> { <span class="pl-c">// On every insert, remove and update:</span>
indexes<span class="pl-k">:</span> <span class="pl-c1">true</span>, <span class="pl-c">// Updates the indexes, if any</span>
@@ -382,12 +374,12 @@
log<span class="pl-k">:</span> logFunc, <span class="pl-c">// Default stdout</span>
logCtx<span class="pl-k">:</span> logCtx <span class="pl-c">// The context of execution for the log function</span>
nddb_pointer<span class="pl-k">:</span> <span class="pl-c1">4</span>, <span class="pl-c">// Set the pointer to element of index 4</span>
- <span class="pl-en">globalCompare</span>: <span class="pl-st">function</span>(<span class="pl-vpf">o1</span>, <span class="pl-vpf">o2</span>) {
+ <span class="pl-en">globalCompare</span><span class="pl-k">:</span> <span class="pl-k">function</span>(<span class="pl-smi">o1</span>, <span class="pl-smi">o2</span>) {
<span class="pl-c">// comparing code</span>
},
filters<span class="pl-k">:</span> { <span class="pl-c">// Extends NDDB with new operators for select queries</span>
- <span class="pl-s1"><span class="pl-pds">'</span><span class="pl-en">%</span><span class="pl-pds">'</span></span>: <span class="pl-st">function</span>(<span class="pl-vpf">d</span>, <span class="pl-vpf">value</span>, <span class="pl-vpf">comparator</span>){
- <span class="pl-k">return</span> <span class="pl-st">function</span>(<span class="pl-vpf">elem</span>) {
+ <span class="pl-s"><span class="pl-pds">'</span><span class="pl-en">%</span><span class="pl-pds">'</span></span><span class="pl-k">:</span> <span class="pl-k">function</span>(<span class="pl-smi">d</span>, <span class="pl-smi">value</span>, <span class="pl-smi">comparator</span>){
+ <span class="pl-k">return</span> <span class="pl-k">function</span>(<span class="pl-smi">elem</span>) {
<span class="pl-k">if</span> ((elem[d] <span class="pl-k">%</span> value) <span class="pl-k">===</span> <span class="pl-c1">0</span>) {
<span class="pl-k">return</span> elem;
}
@@ -399,28 +391,178 @@
}
}
-<span class="pl-s">var</span> nddb <span class="pl-k">=</span> <span class="pl-k">new</span> <span class="pl-en">NDDB</span>(options);
+<span class="pl-k">var</span> nddb <span class="pl-k">=</span> <span class="pl-k">new</span> <span class="pl-en">NDDB</span>(options);
<span class="pl-c">// or</span>
nddb <span class="pl-k">=</span> <span class="pl-k">new</span> <span class="pl-en">NDDB</span>();
nddb.init(options);</pre></div>
<h2>
-<a id="save-and-load-from-file-or-to-localstorage" class="anchor" href="#save-and-load-from-file-or-to-localstorage" aria-hidden="true"><span class="octicon octicon-link"></span></a>Save and load from file or to localStorage</h2>
+<a id="saving-and-loading-items" class="anchor" href="#saving-and-loading-items" aria-hidden="true"><span class="octicon octicon-link"></span></a>Saving and Loading Items</h2>
+
+<p>The items in the database can be saved and loaded using the <code>save</code> and
+<code>load</code> methods, and their synchronous implementations <code>saveSync</code> and
+<code>loadSync</code>.</p>
+
+<h3>
+<a id="saving-and-loading-to-file-system-nodejs-environment" class="anchor" href="#saving-and-loading-to-file-system-nodejs-environment" aria-hidden="true"><span class="octicon octicon-link"></span></a>Saving and loading to file system (node.js environment)</h3>
+
+<p>Two formats are natively supported: <code>.json</code> and <code>.csv</code>, and they are
+detected by the extension of the filename. If a differ extension is
+found, NDDB will fall back to the default format (usually json).</p>
+
+<p>It is possible to specify new formats using the <code>addFormat</code> method.</p>
+
+<h4>
+<a id="code-examples" class="anchor" href="#code-examples" aria-hidden="true"><span class="octicon octicon-link"></span></a>Code Examples</h4>
+
+<div class="highlight highlight-source-js"><pre><span class="pl-c">// Saving items in JSON format.</span>
+db.save(<span class="pl-s"><span class="pl-pds">'</span>db.json<span class="pl-pds">'</span></span>, <span class="pl-k">function</span>() {
+ <span class="pl-en">console</span>.<span class="pl-c1">log</span>(<span class="pl-s"><span class="pl-pds">"</span>Saved db into 'db.json'<span class="pl-pds">"</span></span>);
+});
+
+<span class="pl-c">// Saving items in CSV format.</span>
+db.save(<span class="pl-s"><span class="pl-pds">'</span>db.csv<span class="pl-pds">'</span></span>, <span class="pl-k">function</span>() {
+ <span class="pl-en">console</span>.<span class="pl-c1">log</span>(<span class="pl-s"><span class="pl-pds">"</span>Saved db into db.csv'<span class="pl-pds">"</span></span>);
+});
+
+<span class="pl-c">// Saving items synchronously in CSV format.</span>
+db.saveSync(<span class="pl-s"><span class="pl-pds">'</span>db.csv<span class="pl-pds">'</span></span>);
+<span class="pl-en">console</span>.<span class="pl-c1">log</span>(<span class="pl-s"><span class="pl-pds">"</span>Saved db into db.csv'<span class="pl-pds">"</span></span>);
+
+<span class="pl-c">// Saving items in the default format (usually json).</span>
+db.getDefaultFormat(); <span class="pl-c">// json</span>
+db.save(<span class="pl-s"><span class="pl-pds">'</span>db.out<span class="pl-pds">'</span></span>, <span class="pl-k">function</span>() {
+ <span class="pl-en">console</span>.<span class="pl-c1">log</span>(<span class="pl-s"><span class="pl-pds">"</span>Saved db into db.out'<span class="pl-pds">"</span></span>);
+});
+
+<span class="pl-c">// Specifying the default format and saving into CSV.</span>
+db.setDefaultFormat(<span class="pl-s"><span class="pl-pds">'</span>csv<span class="pl-pds">'</span></span>);
+db.save(<span class="pl-s"><span class="pl-pds">'</span>db.out<span class="pl-pds">'</span></span>, <span class="pl-k">function</span>() {
+ <span class="pl-en">console</span>.<span class="pl-c1">log</span>(<span class="pl-s"><span class="pl-pds">"</span>Saved db into db.out'<span class="pl-pds">"</span></span>);
+});
+
+<span class="pl-c">// Transform items before saving them to CSV format.</span>
+<span class="pl-c">// Define adapter function that doubles all numbers in column "A".</span>
+<span class="pl-k">var</span> options <span class="pl-k">=</span> {};
+options.adapter <span class="pl-k">=</span> {
+ <span class="pl-en">A</span><span class="pl-k">:</span> <span class="pl-k">function</span>(<span class="pl-smi">item</span>) { <span class="pl-k">return</span> item.A <span class="pl-k">*</span> <span class="pl-c1">2</span>; }
+};
+db.save(<span class="pl-s"><span class="pl-pds">'</span>db2.csv<span class="pl-pds">'</span></span>, options, <span class="pl-k">function</span>() {
+ <span class="pl-en">console</span>.<span class="pl-c1">log</span>(<span class="pl-s"><span class="pl-pds">"</span>Saved db as csv into 'db2.csv', where numbers in column 'A'<span class="pl-pds">"</span></span> <span class="pl-k">+</span>
+ <span class="pl-s"><span class="pl-pds">"</span>were doubled<span class="pl-pds">"</span></span>);
+});
+
+
+<span class="pl-c">// Loading items into database.</span>
+db.<span class="pl-c1">load</span>(<span class="pl-s"><span class="pl-pds">'</span>db.csv<span class="pl-pds">'</span></span>, <span class="pl-k">function</span>() {
+ <span class="pl-en">console</span>.<span class="pl-c1">log</span>(<span class="pl-s"><span class="pl-pds">"</span>Loaded csv file into database<span class="pl-pds">"</span></span>);
+});
+
+<span class="pl-c">// Loading items into database synchronously.</span>
+db.loadSync(<span class="pl-s"><span class="pl-pds">'</span>db.csv<span class="pl-pds">'</span></span>);
+<span class="pl-en">console</span>.<span class="pl-c1">log</span>(<span class="pl-s"><span class="pl-pds">"</span>Loaded csv file into database<span class="pl-pds">"</span></span>);
+
+<span class="pl-c">// Loading 'adapted' items into database.</span>
+db.<span class="pl-c1">load</span>(<span class="pl-s"><span class="pl-pds">'</span>db2.csv<span class="pl-pds">'</span></span>, <span class="pl-k">function</span>() {
+ <span class="pl-en">console</span>.<span class="pl-c1">log</span>(<span class="pl-s"><span class="pl-pds">"</span>Loaded csv file into database<span class="pl-pds">"</span></span>);
+});
+
+<span class="pl-c">// Transform items before loading them into database.</span>
+<span class="pl-c">// Loading items into database.</span>
+<span class="pl-k">var</span> options <span class="pl-k">=</span> {};
+options.adapter <span class="pl-k">=</span> {
+ <span class="pl-en">A</span><span class="pl-k">:</span> <span class="pl-k">function</span>(<span class="pl-smi">item</span>) { <span class="pl-k">return</span> item.A <span class="pl-k">/</span> <span class="pl-c1">2</span>; }
+};
+
+db.<span class="pl-c1">load</span>(<span class="pl-s"><span class="pl-pds">'</span>db2.csv<span class="pl-pds">'</span></span>, <span class="pl-k">function</span>() {
+ <span class="pl-en">console</span>.<span class="pl-c1">log</span>(<span class="pl-s"><span class="pl-pds">"</span>Loaded csv file into database<span class="pl-pds">"</span></span>);
+});
+
+<span class="pl-c">// Specify a new format.</span>
+db.addFormat(<span class="pl-s"><span class="pl-pds">'</span>asd<span class="pl-pds">'</span></span>, {
+ <span class="pl-en">save</span><span class="pl-k">:</span> <span class="pl-k">function</span>(<span class="pl-smi">db</span>, <span class="pl-smi">file</span>, <span class="pl-smi">cb</span>, <span class="pl-smi">options</span>) {
+ <span class="pl-c">// save file asynchronously.</span>
+ },
+ <span class="pl-en">load</span><span class="pl-k">:</span> <span class="pl-k">function</span>(<span class="pl-smi">db</span>, <span class="pl-smi">file</span>, <span class="pl-smi">cb</span>, <span class="pl-smi">options</span>) {
+ <span class="pl-c">// load file asynchronously.</span>
+ },
+ <span class="pl-en">saveSync</span><span class="pl-k">:</span> <span class="pl-k">function</span>(<span class="pl-smi">db</span>, <span class="pl-smi">file</span>, <span class="pl-smi">cb</span>, <span class="pl-smi">options</span>) {
+ <span class="pl-c">// save file synchronously.</span>
+ },
+ <span class="pl-en">loadSync</span><span class="pl-k">:</span> <span class="pl-k">function</span>(<span class="pl-smi">db</span>, <span class="pl-smi">file</span>, <span class="pl-smi">cb</span>, <span class="pl-smi">options</span>) {
+ <span class="pl-c">// load file synchronously.</span>
+ }
+});
+
+<span class="pl-c">// Saving in the new format.</span>
+db.save(<span class="pl-s"><span class="pl-pds">'</span>db.asd<span class="pl-pds">'</span></span>);</pre></div>
+
+<h4>
+<a id="list-of-all-available-options" class="anchor" href="#list-of-all-available-options" aria-hidden="true"><span class="octicon octicon-link"></span></a>List of all available options</h4>
+
+<div class="highlight highlight-source-js"><pre>{
+
+ flags<span class="pl-k">:</span> <span class="pl-s"><span class="pl-pds">'</span>w<span class="pl-pds">'</span></span>, <span class="pl-c">// The Node.js flag to write to fs.</span>
+ <span class="pl-c">// Default: 'a' (append).</span>
+
+ encoding<span class="pl-k">:</span> <span class="pl-s"><span class="pl-pds">'</span>utf-8<span class="pl-pds">'</span></span>, <span class="pl-c">// The encoding of the file.</span>
+
+ mode<span class="pl-k">:</span> <span class="pl-c1">0777</span>, <span class="pl-c">// The permission given to the file.</span>
+ <span class="pl-c">// Default: 0666</span>
+
+ <span class="pl-c">// Options below are processed when the CSV format is detected.</span>
+
+ headers<span class="pl-k">:</span> <span class="pl-c1">true</span>, <span class="pl-c">// if options.headers === true: use</span>
+ <span class="pl-c">// first line of file as headers;</span>
+ <span class="pl-c">// if !options.headers: use</span>
+ <span class="pl-c">// ['X1'...'XN'] as headers;</span>
+ <span class="pl-c">// if options.headers is an array of</span>
+ <span class="pl-c">// strings use it as headers;</span>
+ <span class="pl-c">// if options.headers is an array</span>
+ <span class="pl-c">// containing true/false use entry</span>
+ <span class="pl-c">// from file/'Xi' respectively;</span>
-<p>In the node.js environment, it is possible to save the state of the
-database to a file and load it afterwards.</p>
-<div class="highlight highlight-javascript"><pre><span class="pl-c">// Database exists and items inserted.</span>
-db.save(<span class="pl-s1"><span class="pl-pds">'</span>./db.out<span class="pl-pds">'</span></span>);
+ adapter<span class="pl-k">:</span> { <span class="pl-en">A</span><span class="pl-k">:</span> <span class="pl-k">function</span>(<span class="pl-smi">row</span>) { <span class="pl-c">// An obj containing callbacks for</span>
+ <span class="pl-k">return</span> row[<span class="pl-s"><span class="pl-pds">'</span>A<span class="pl-pds">'</span></span>]<span class="pl-k">-</span><span class="pl-c1">1</span>; <span class="pl-c">// each header. The callbacks take</span>
+ } <span class="pl-c">// an object of strings and</span>
+ }, <span class="pl-c">// return a string. Each entry in</span>
+ <span class="pl-c">// the file is the result of</span>
+ <span class="pl-c">// applying the callback of its</span>
+ <span class="pl-c">// column to its row.</span>
-<span class="pl-s">var</span> db2 <span class="pl-k">=</span> <span class="pl-k">new</span> <span class="pl-en">NDDB</span>();
-db2.<span class="pl-s3">load</span>(<span class="pl-s1"><span class="pl-pds">'</span>./db.out<span class="pl-pds">'</span></span>);</pre></div>
-<p>The above command are valid also in the browser environment if
-<a href="https://github.com/shakty/shelf.js">Shelf.js</a> is loaded. A string id
-instead of the path to a file must be given instead.</p>
+ separator<span class="pl-k">:</span> <span class="pl-s"><span class="pl-pds">'</span>,<span class="pl-pds">'</span></span>, <span class="pl-c">// The character used as separator</span>
+ <span class="pl-c">// between values. Default ','.</span>
+
+ quote<span class="pl-k">:</span> <span class="pl-s"><span class="pl-pds">'</span>"<span class="pl-pds">'</span></span>, <span class="pl-c">// The character used as quote.</span>
+ <span class="pl-c">// Default: '"'.</span>
+
+ commentchar<span class="pl-k">:</span> <span class="pl-s"><span class="pl-pds">'</span><span class="pl-pds">'</span></span>, <span class="pl-c">// The character used for comments.</span>
+ <span class="pl-c">// Default: ''.</span>
+
+ nestedQuotes<span class="pl-k">:</span> <span class="pl-c1">false</span>, <span class="pl-c">// TRUE, if nested quotes allowed.</span>
+ <span class="pl-c">// Default FALSE.</span>
+
+ escapeCharacter<span class="pl-k">:</span> <span class="pl-s"><span class="pl-pds">'</span><span class="pl-cce">\\</span><span class="pl-pds">'</span></span>, <span class="pl-c">// The char that should be skipped.</span>
+ <span class="pl-c">// Default: \.</span>
+}</pre></div>
+
+<h3>
+<a id="saving-and-loading-to-the-local-storage-browser-environment" class="anchor" href="#saving-and-loading-to-the-local-storage-browser-environment" aria-hidden="true"><span class="octicon octicon-link"></span></a>Saving and loading to the local storage (browser environment)</h3>
+
+<p>Items persistance in the browser is available only if NDDB is built
+with the <a href="https://github.com/shakty/shelf.js">Shelf.js</a>
+extension. Alternatively, a custom <code>store</code> function taking as input
+the name of the local database could be defined.</p>
+
+<p>All items will be saved in the JSON format.</p>
+
+<p>Notice that there exist limitations to maximum number of items that
+can be saved, depending on the local storage maximum capacity settings
+of the browser. If the limit is reached an error will be thrown.</p>
<h2>
<a id="test" class="anchor" href="#test" aria-hidden="true"><span class="octicon octicon-link"></span></a>Test</h2>
@@ -443,54 +585,37 @@
separately, or create a new build that includes it already. See the
build help for options.</p>
-<div class="highlight highlight-javascript"><pre>node make.nddb.js build <span class="pl-c">// Standard build,</span>
+<div class="highlight highlight-source-js"><pre>node make.nddb.js build <span class="pl-c">// Standard build,</span>
node make.nddb.js build <span class="pl-k">-</span>a <span class="pl-k">-</span>o nddb<span class="pl-k">-</span>full <span class="pl-c">// Full build</span></pre></div>
<p>The build file file will be created inside the <code>build/</code> directory.</p>
<h3>
<a id="help" class="anchor" href="#help" aria-hidden="true"><span class="octicon octicon-link"></span></a>Help</h3>
-<div class="highlight highlight-javascript"><pre>node make.nddb.js <span class="pl-k">--</span>help</pre></div>
+<div class="highlight highlight-source-js"><pre>node make.nddb.js <span class="pl-k">--</span>help</pre></div>
<h2>
<a id="api-documentation" class="anchor" href="#api-documentation" aria-hidden="true"><span class="octicon octicon-link"></span></a>API Documentation</h2>
<p>Create html API documentation using the make file in the bin directory:</p>
-<div class="highlight highlight-javascript"><pre>node make.nddb.js doc</pre></div>
+<div class="highlight highlight-source-js"><pre>node make.nddb.js doc</pre></div>
<h2>
<a id="license" class="anchor" href="#license" aria-hidden="true"><span class="octicon octicon-link"></span></a>License</h2>
-<p>Copyright (C) 2014 Stefano Balietti</p>
-
-<p>Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:</p>
-
-<p>The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.</p>
-
-<p>THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.</p>
- </section>
- </div>
- <footer>
- <p>Project maintained by <a href="https://github.com/nodeGame">nodeGame</a></p>
- <p>Hosted on GitHub Pages &mdash; Theme by <a href="https://github.com/orderedlist">orderedlist</a></p>
- </footer>
- <!--[if !IE]><script>fixScale(document);</script><![endif]-->
- <script type="text/javascript">
+<p><a href="LICENSE">MIT</a></p>
+
+ <footer class="site-footer">
+ <span class="site-footer-owner"><a href="https://github.com/nodeGame/NDDB">Nddb</a> is maintained by <a href="https://github.com/nodeGame">nodeGame</a>.</span>
+
+ <span class="site-footer-credits">This page was generated by <a href="https://pages.github.com">GitHub Pages</a> using the <a href="https://github.com/jasonlong/cayman-theme">Cayman theme</a> by <a href="https://twitter.com/jasonlong">Jason Long</a>.</span>
+ </footer>
+
+ </section>
+
+ <script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
@@ -502,4 +627,4 @@
</script>
</body>
-</html>
+</html>
View
2 params.json
@@ -1 +1 @@
-{"name":"Nddb","tagline":"Javascript lightweight N-dimensional database","body":"# NDDB\r\n\r\n[![Build Status](https://travis-ci.org/nodeGame/NDDB.png?branch=master)](https://travis-ci.org/nodeGame/NDDB)\r\n\r\nNDDB is a powerful and versatile object database for node.js and the browser.\r\n\r\n---\r\n\r\nNDDB (N-Dimensional DataBase) supports indexes, views, hashes, joins,\r\ngroup-by, basic statistics, custom operations, saving and loading from\r\nfile system and browser localStorage, and much more.\r\n\r\nDeveloper-friendly thanks to an easy api, detailed documentation, and\r\n**100%** test coverage.\r\n\r\n## List of features\r\n\r\n- Selecting: `select`, `and`, `or`\r\n- Sorting: `sort`, `reverse`, `last`, `first`, `limit`, `distinct`,\r\n `shuffle`\r\n- Indexing: `view`, `index`, `hash`, `comparator`\r\n- Custom callbacks: `map`, `each`, `filter`\r\n- Updating and Deletion: `update`, `remove`, `clear`\r\n- Advanced operations: `split`, `join`, `concat`, `groupBy`\r\n- Fetching and transformations: `fetch`, `fetchArray`,\r\n `fetchKeyArray`, `fetchValues`, `fetchSubObj`\r\n- Statistics operator: `count`, `max`, `min`, `mean`, `stddev`\r\n- Diff: `diff`, `intersect`\r\n- Skim: `skim`, `keep`\r\n- Iterator: `previous`, `next`, `first`, `last`\r\n- Tagging: `tag`\r\n- Event listener / emitter: `on`, `off`, `emit`\r\n- Saving and Loading: `save`, `load`, `loadCSV`\r\n\r\nThe complete NDDB api documentation is available\r\n[here](http://nodegame.github.com/NDDB/docs/nddb.js.html).\r\n\r\n## Usage\r\n\r\nLoad the library in Node.js:\r\n\r\n```javascript\r\nvar NDDB = require('NDDB').NDDB;\r\n```\r\n\r\nor in the browser add a script tag in the page:\r\n\r\n```html\r\n<!-- Must load a version of NDDB that includes JSUS (see 'build/' dir) -->\r\n<script src=\"/path/to/nddb.js\"></script>\r\n```\r\n\r\nCreate an instance of NDDB:\r\n\r\n```javascript \r\nvar db = new NDDB();\r\n```\r\n\r\nInsert an item into the database:\r\n\r\n```javascript\r\ndb.insert({\r\n painter: \"Picasso\",\r\n title: \"Les Demoiselles d'Avignon\",\r\n year: 1907\r\n});\r\n```\r\n\r\nImport a collection of items:\r\n\r\n```javascript\r\nvar items = [\r\n {\r\n painter: \"Dali\",\r\n title: \"Portrait of Paul Eluard\",\r\n year: 1929,\r\n portrait: true\r\n },\r\n {\r\n painter: \"Dali\",\r\n title: \"Barcelonese Mannequin\",\r\n year: 1927\r\n },\r\n {\r\n painter: \"Monet\",\r\n title: \"Water Lilies\",\r\n year: 1906\r\n },\r\n {\r\n painter: \"Monet\",\r\n title: \"Wheatstacks (End of Summer)\",\r\n year: 1891\r\n },\r\n {\r\n painter: \"Manet\",\r\n title: \"Olympia\",\r\n year: 1863\r\n }\r\n];\r\n\r\ndb.importDB(items);\r\n```\r\n\r\nRetrieve the database size:\r\n\r\n```javascript\r\nvar db_size = db.size(); // 6\r\n```\r\n\r\n### Select Items\r\n\r\nSelect statements must begin with `select`, and can be concatened by\r\nany number of subsequent `and` and `or` statements. The comparison in\r\nselect statements is performed using three input parameters: \r\n\r\n - 'property'\r\n - 'operator'\r\n - any additional number of arguments required by operator\r\n\r\nAvailable operators include standard logical operators:\r\n\r\n - `=`, `==`, `!=`, ``>`, >=`, `<`, `<=`,\r\n\r\nor advanced comparison operators:\r\n\r\n - `E`: field exists (can be omitted, it is the default one)\r\n - `><`: between values (expects array)\r\n - `<>`: not between values (expects array)\r\n - `in`: element is found in array (expects array)\r\n - `!in`: element is noi found in array (expects array)\r\n - `LIKE`: string SQL LIKE (case sensitive)\r\n - `iLIKE`: string SQL LIKE (case insensitive)\r\n\r\nIt is possible to access and compare nested properties simply\r\nseparating them with `.`.\r\n\r\nAfter a selection is finished, items can be returned using one of the\r\n`fetch` statements.\r\n\r\n#### Select Examples\r\n\r\nSelect all paintings from Dali:\r\n\r\n```javascript\r\ndb.select('painter', '=', 'Dali'); // 2 items\r\n```\r\n\r\nCase sensitive `LIKE` operator:\r\n\r\n```javascript\r\ndb.select('painter', 'LIKE', 'M_net'); // 3 items\r\n```\r\n\r\nSelect on multiple properties (`*`) with case insensitive `LIKE`:\r\n\r\n```javascript\r\ndb.select('*', 'iLIKE', '%e%'); // All items\r\ndb.select(['painter', 'portrait'], 'iLIKE', '%e%') // 5 items\r\n```\r\n\r\nSelect all portraits:\r\n\r\n```javascript\r\ndb.select('portrait'); // 1 item\r\n```\r\n\r\nFetch all paintings from Dali that are before 1928:\r\n\r\n```javascript\r\ndb.select('painter', '=', 'Dali')\r\n .and('year', '<', 1928);\r\n .fetch(); // 1 item\r\n```\r\n\r\nFetch all paintings of the beginning of XX's century:\r\n\r\n```javascript\r\n db.select('year', '><', [1900, 1910])\r\n .fetch(); // 2 items\r\n```\r\n\r\nFetch separately all the painters and all the dates of the paintings:\r\n\r\n```javascript\r\ndb.select('year', '><', [1900, 1910])\r\n .fetchValues(['painter', 'title']);\r\n\r\n// { painter: [ 'Jesus', 'Dali', 'Dali', 'Monet', 'Monet', 'Manet' ],\r\n// year: [ 0, 1929, 1927, 1906, 1891, 1863 ] }\r\n```\r\n\r\n### Sorting\r\n\r\nDefine a global comparator function that sorts all the entries chronologically:\r\n\r\n```javascript\r\ndb.globalCompator = function (o1, o2) {\r\n if (o1.year < o2.year) return 1;\r\n if (o1.year < o2.year) return 2;\r\n return 0;\r\n};\r\n```\r\n\r\nSort all the items (global comparator function is automatically used):\r\n\r\n```javascript\r\ndb.sort(); // Order: Manet, Monet, Monet, Picasso, Dali, Dali\r\n```\r\n\r\nReverse the order of the items:\r\n\r\n```javascript\r\ndb.reverse(); // Order: Dali, Dali, Picasso, Monet, Monet, Manet\r\n```\r\n\r\nDefine a custom comparator function for the name of the painter, which\r\ngives highest priorities to the canvases of Picasso;\r\n\r\n```javascript\r\ndb.compare('painter', function (o1, o2) {\r\n if (o1.painter === 'Picasso') return -1;\r\n if (o2.painter === 'Picasso') return 1;\r\n}\r\n```\r\n\r\nSort all the paintings by painter\r\n\r\n```javascript\r\ndb.sort('painter'); // Picasso is always listed first\r\n```\r\n\r\n### Views\r\n\r\nSplits the database in sub-database, each containing semantically\r\nconsistent set of entries:\r\n\r\n```javascript\r\n// Let us add some cars to our previous database of paintings.\r\nvar not_art_items = [\r\n {\r\n car: \"Ferrari\",\r\n model: \"F10\",\r\n speed: 350,\r\n },\r\n {\r\n car: \"Fiat\",\r\n model: \"500\",\r\n speed: 100,\r\n },\r\n {\r\n car: \"BMW\",\r\n model: \"Z4\",\r\n speed: 250,\r\n },\r\n];\r\n\r\ndb.view('art', function(o) {\r\n return o.painter;\r\n});\r\n\r\ndb.view('cars', function(o) {\r\n return o.car;\r\n});\r\n\r\ndb.rebuildIndexes();\r\n\r\ndb.size(); // 9\r\ndb.art.size(); // NDDB with 6 art entries\r\ndb.cars.size(); // NDDB with 3 car entries\r\n```\r\n\r\n### Hashing\r\n\r\nDefine a custom hash function that creates a new view on each of the\r\npainters in the database:\r\n\r\n```javascript\r\ndb.hash('painter', function(o) {\r\n if (!o) return undefined;\r\n return o.painter;\r\n});\r\n\r\ndb.rebuildIndexes();\r\n\r\ndb.size(); // 6, unchanged;\r\ndb.painter.Picasso; // NDDB with 1 element in db\r\ndb.painter.Monet // NDDB with 2 elements in db\r\ndb.painter.Manet // NDDB with 1 elements in db\r\ndb.painter.Dali // NDDB with 2 elements in db\r\n```\r\n\r\n### Listenting to events\r\n\r\nListen to the `insert` event and modify the inserted items by adding\r\nan external index to them:\r\n\r\n```javascript\r\nvar id = 0;\r\nfunction getMyId(){ return id++; };\r\n\r\ndb.on('insert', function(o) {\r\n o.painter.id = getMyId();\r\n});\r\n```\r\n\r\n### Indexes\r\n\r\nDefine a custom indexing function that gives fast, direct access to\r\nthe items of the database;\r\n\r\n```javascript\r\ndb.index('pid', function(o) {\r\n return o.id;\r\n});\r\n\r\ndb.rebuildIndexes();\r\n\r\ndb.pid.get(0).name; // Picasso\r\n\r\ndb.pid.update(0, {\r\n comment: \"Good job Pablo!\"\r\n});\r\n\r\n// Counts items in selection.\r\ndb.select('comment').count(); // 1\r\n\r\nvar picasso = db.pid.remove(0);\r\ndb.size(); // (0)\r\n\r\n// Get all available keys in the index\r\ndb.painter.getAllKeys(); // ['0','1', ... ]\r\n\r\n// Get all elements indexed by their key in one object\r\ndb.painter.getAllKeyElements();\r\n```\r\n\r\n## Example of a configuration object\r\n\r\n```javascript\r\nvar logFunc = function(txt, level) {\r\n if (level > 0) {\r\n console.log(txt);\r\n }\r\n};\r\n\r\nvar options = {\r\n tags: {}, // Collection of tags\r\n update: { // On every insert, remove and update:\r\n indexes: true, // Updates the indexes, if any\r\n sort: true, // Sorts the items of the database\r\n pointer: true, // Moves the iterator to the last inserted element\r\n },\r\n C: {}, // Collection of comparator functions\r\n H: {}, // Collection of hashing functions\r\n I: {}, // Collection of indexing functions\r\n V: {}, // Collection of view functions\r\n log: logFunc, // Default stdout\r\n logCtx: logCtx // The context of execution for the log function\r\n nddb_pointer: 4, // Set the pointer to element of index 4\r\n globalCompare: function(o1, o2) {\r\n // comparing code\r\n },\r\n filters: { // Extends NDDB with new operators for select queries\r\n '%': function(d, value, comparator){\r\n return function(elem) {\r\n if ((elem[d] % value) === 0) {\r\n return elem;\r\n }\r\n }\r\n },\r\n share: { // Contains objects that are copied by reference to\r\n // in every new instance of NDDB.\r\n sharedObj: sharedObj\r\n }\r\n}\r\n\r\nvar nddb = new NDDB(options);\r\n\r\n// or\r\n\r\nnddb = new NDDB();\r\nnddb.init(options);\r\n```\r\n\r\n## Save and load from file or to localStorage\r\n\r\nIn the node.js environment, it is possible to save the state of the\r\ndatabase to a file and load it afterwards.\r\n\r\n```javascript\r\n// Database exists and items inserted.\r\ndb.save('./db.out');\r\n\r\nvar db2 = new NDDB();\r\ndb2.load('./db.out');\r\n```\r\n\r\nThe above command are valid also in the browser environment if\r\n[Shelf.js](https://github.com/shakty/shelf.js) is loaded. A string id\r\ninstead of the path to a file must be given instead.\r\n\r\n## Test\r\n\r\nNDDB relies on [mocha](http://visionmedia.github.com/mocha/) and\r\n[should.js](http://github.com/visionmedia/should.js) for testing.\r\n\r\n $ npm install # will load all necessary dependencies\r\n $ npm test # will run the test suite against nddb.js\r\n\r\n## Build\r\n\r\nCreate your customized build of NDDB using the make file in the `bin`\r\ndirectory:\r\n\r\n\r\nIn order to run in the browser NDDB needs to have\r\n[JSUS](http://github.com/nodeGame/JSUS) loaded. You can include it\r\nseparately, or create a new build that includes it already. See the\r\nbuild help for options.\r\n\r\n```javascript\r\nnode make.nddb.js build // Standard build,\r\nnode make.nddb.js build -a -o nddb-full // Full build\r\n```\r\n\r\nThe build file file will be created inside the `build/` directory.\r\n\r\n\r\n### Help\r\n\r\n```javascript\r\nnode make.nddb.js --help\r\n```\r\n\r\n## API Documentation\r\n\r\nCreate html API documentation using the make file in the bin directory:\r\n\r\n```javascript\r\nnode make.nddb.js doc\r\n```\r\n\r\n## License\r\n\r\nCopyright (C) 2014 Stefano Balietti\r\n\r\nPermission is hereby granted, free of charge, to any person obtaining\r\na copy of this software and associated documentation files (the\r\n\"Software\"), to deal in the Software without restriction, including\r\nwithout limitation the rights to use, copy, modify, merge, publish,\r\ndistribute, sublicense, and/or sell copies of the Software, and to\r\npermit persons to whom the Software is furnished to do so, subject to\r\nthe following conditions:\r\n\r\nThe above copyright notice and this permission notice shall be\r\nincluded in all copies or substantial portions of the Software.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\r\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\r\nLIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\r\nOF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\r\nWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r\n","google":"UA-34089835-1","note":"Don't delete this file! It's used internally to help with page regeneration."}
+{"name":"Nddb","tagline":"Javascript lightweight N-dimensional database","body":"# NDDB\r\n\r\n[![Build Status](https://travis-ci.org/nodeGame/NDDB.png?branch=master)](https://travis-ci.org/nodeGame/NDDB)\r\n\r\nNDDB is a powerful and versatile object database for node.js and the browser.\r\n\r\n---\r\n\r\nNDDB (N-Dimensional DataBase) supports indexes, views, hashes, joins,\r\ngroup-by, basic statistics, custom operations, saving and loading from\r\nfile system and browser localStorage, and much more.\r\n\r\nDeveloper-friendly thanks to an easy api, detailed documentation, and\r\n**100%** test coverage.\r\n\r\n## List of features\r\n\r\n- Selecting: `select`, `and`, `or`\r\n- Sorting: `sort`, `reverse`, `last`, `first`, `limit`, `distinct`,\r\n `shuffle`\r\n- Indexing: `view`, `index`, `hash`, `comparator`\r\n- Custom callbacks: `map`, `each`, `filter`\r\n- Updating and Deletion: `update`, `remove`, `clear`\r\n- Advanced operations: `split`, `join`, `concat`, `groupBy`\r\n- Fetching and transformations: `fetch`, `fetchArray`,\r\n `fetchKeyArray`, `fetchValues`, `fetchSubObj`\r\n- Statistics operator: `count`, `max`, `min`, `mean`, `stddev`\r\n- Diff: `diff`, `intersect`\r\n- Skim: `skim`, `keep`\r\n- Iterator: `previous`, `next`, `first`, `last`\r\n- Tagging: `tag`\r\n- Event listener / emitter: `on`, `off`, `emit`\r\n- Saving and Loading: `save`, `saveSync`, `load`, `loadSync`\r\n\r\nThe complete NDDB api documentation is available\r\n[here](http://nodegame.github.com/NDDB/docs/nddb.js.html).\r\n\r\n## Usage\r\n\r\nLoad the library in Node.js:\r\n\r\n```javascript\r\nvar NDDB = require('NDDB').NDDB;\r\n```\r\n\r\nor in the browser add a script tag in the page:\r\n\r\n```html\r\n<!-- Must load a version of NDDB that includes JSUS (see 'build/' dir) -->\r\n<script src=\"/path/to/nddb.js\"></script>\r\n```\r\n\r\nCreate an instance of NDDB:\r\n\r\n```javascript\r\nvar db = new NDDB();\r\n```\r\n\r\nInsert an item into the database:\r\n\r\n```javascript\r\ndb.insert({\r\n painter: \"Picasso\",\r\n title: \"Les Demoiselles d'Avignon\",\r\n year: 1907\r\n});\r\n```\r\n\r\nImport a collection of items:\r\n\r\n```javascript\r\nvar items = [\r\n {\r\n painter: \"Dali\",\r\n title: \"Portrait of Paul Eluard\",\r\n year: 1929,\r\n portrait: true\r\n },\r\n {\r\n painter: \"Dali\",\r\n title: \"Barcelonese Mannequin\",\r\n year: 1927\r\n },\r\n {\r\n painter: \"Monet\",\r\n title: \"Water Lilies\",\r\n year: 1906\r\n },\r\n {\r\n painter: \"Monet\",\r\n title: \"Wheatstacks (End of Summer)\",\r\n year: 1891\r\n },\r\n {\r\n painter: \"Manet\",\r\n title: \"Olympia\",\r\n year: 1863\r\n }\r\n];\r\n\r\ndb.importDB(items);\r\n```\r\n\r\nRetrieve the database size:\r\n\r\n```javascript\r\nvar db_size = db.size(); // 6\r\n```\r\n\r\n### Select Items\r\n\r\nSelect statements must begin with `select`, and can be concatened by\r\nany number of subsequent `and` and `or` statements. The comparison in\r\nselect statements is performed using three input parameters:\r\n\r\n - 'property'\r\n - 'operator'\r\n - any additional number of arguments required by operator\r\n\r\nAvailable operators include standard logical operators:\r\n\r\n - `=`, `==`, `!=`, `>`, >=`, `<`, `<=`,\r\n\r\nor advanced comparison operators:\r\n\r\n - `E`: field exists (can be omitted, it is the default one)\r\n - `><`: between values (expects array)\r\n - `<>`: not between values (expects array)\r\n - `in`: element is found in array (expects array)\r\n - `!in`: element is noi found in array (expects array)\r\n - `LIKE`: string SQL LIKE (case sensitive)\r\n - `iLIKE`: string SQL LIKE (case insensitive)\r\n\r\nIt is possible to access and compare nested properties simply\r\nseparating them with `.`.\r\n\r\nAfter a selection is finished, items can be returned using one of the\r\n`fetch` statements.\r\n\r\n#### Select Examples\r\n\r\nSelect all paintings from Dali:\r\n\r\n```javascript\r\ndb.select('painter', '=', 'Dali'); // 2 items\r\n```\r\n\r\nCase sensitive `LIKE` operator:\r\n\r\n```javascript\r\ndb.select('painter', 'LIKE', 'M_net'); // 3 items\r\n```\r\n\r\nSelect on multiple properties (`*`) with case insensitive `LIKE`:\r\n\r\n```javascript\r\ndb.select('*', 'iLIKE', '%e%'); // All items\r\ndb.select(['painter', 'portrait'], 'iLIKE', '%e%') // 5 items\r\n```\r\n\r\nSelect all portraits:\r\n\r\n```javascript\r\ndb.select('portrait'); // 1 item\r\n```\r\n\r\nFetch all paintings from Dali that are before 1928:\r\n\r\n```javascript\r\ndb.select('painter', '=', 'Dali')\r\n .and('year', '<', 1928);\r\n .fetch(); // 1 item\r\n```\r\n\r\nFetch all paintings of the beginning of XX's century:\r\n\r\n```javascript\r\n db.select('year', '><', [1900, 1910])\r\n .fetch(); // 2 items\r\n```\r\n\r\nFetch separately all the painters and all the dates of the paintings:\r\n\r\n```javascript\r\ndb.select('year', '><', [1900, 1910])\r\n .fetchValues(['painter', 'title']);\r\n\r\n// { painter: [ 'Jesus', 'Dali', 'Dali', 'Monet', 'Monet', 'Manet' ],\r\n// year: [ 0, 1929, 1927, 1906, 1891, 1863 ] }\r\n```\r\n\r\n### Sorting\r\n\r\nDefine a global comparator function that sorts all the entries chronologically:\r\n\r\n```javascript\r\ndb.globalCompator = function (o1, o2) {\r\n if (o1.year < o2.year) return 1;\r\n if (o1.year < o2.year) return 2;\r\n return 0;\r\n};\r\n```\r\n\r\nSort all the items (global comparator function is automatically used):\r\n\r\n```javascript\r\ndb.sort(); // Order: Manet, Monet, Monet, Picasso, Dali, Dali\r\n```\r\n\r\nReverse the order of the items:\r\n\r\n```javascript\r\ndb.reverse(); // Order: Dali, Dali, Picasso, Monet, Monet, Manet\r\n```\r\n\r\nDefine a custom comparator function for the name of the painter, which\r\ngives highest priorities to the canvases of Picasso;\r\n\r\n```javascript\r\ndb.compare('painter', function (o1, o2) {\r\n if (o1.painter === 'Picasso') return -1;\r\n if (o2.painter === 'Picasso') return 1;\r\n}\r\n```\r\n\r\nSort all the paintings by painter\r\n\r\n```javascript\r\ndb.sort('painter'); // Picasso is always listed first\r\n```\r\n\r\n### Views\r\n\r\nSplits the database in sub-database, each containing semantically\r\nconsistent set of entries:\r\n\r\n```javascript\r\n// Let us add some cars to our previous database of paintings.\r\nvar not_art_items = [\r\n {\r\n car: \"Ferrari\",\r\n model: \"F10\",\r\n speed: 350,\r\n },\r\n {\r\n car: \"Fiat\",\r\n model: \"500\",\r\n speed: 100,\r\n },\r\n {\r\n car: \"BMW\",\r\n model: \"Z4\",\r\n speed: 250,\r\n },\r\n];\r\n\r\ndb.view('art', function(o) {\r\n return o.painter;\r\n});\r\n\r\ndb.view('cars', function(o) {\r\n return o.car;\r\n});\r\n\r\ndb.rebuildIndexes();\r\n\r\ndb.size(); // 9\r\ndb.art.size(); // NDDB with 6 art entries\r\ndb.cars.size(); // NDDB with 3 car entries\r\n```\r\n\r\n### Hashing\r\n\r\nDefine a custom hash function that creates a new view on each of the\r\npainters in the database:\r\n\r\n```javascript\r\ndb.hash('painter', function(o) {\r\n if (!o) return undefined;\r\n return o.painter;\r\n});\r\n\r\ndb.rebuildIndexes();\r\n\r\ndb.size(); // 6, unchanged;\r\ndb.painter.Picasso; // NDDB with 1 element in db\r\ndb.painter.Monet // NDDB with 2 elements in db\r\ndb.painter.Manet // NDDB with 1 elements in db\r\ndb.painter.Dali // NDDB with 2 elements in db\r\n```\r\n\r\n### Listenting to events\r\n\r\nListen to the `insert` event and modify the inserted items by adding\r\nan external index to them:\r\n\r\n```javascript\r\nvar id = 0;\r\nfunction getMyId(){ return id++; };\r\n\r\ndb.on('insert', function(o) {\r\n o.painter.id = getMyId();\r\n});\r\n```\r\n\r\n### Indexes\r\n\r\nDefine a custom indexing function that gives fast, direct access to\r\nthe items of the database;\r\n\r\n```javascript\r\ndb.index('pid', function(o) {\r\n return o.id;\r\n});\r\n\r\ndb.rebuildIndexes();\r\n\r\ndb.pid.get(0).name; // Picasso\r\n\r\ndb.pid.update(0, {\r\n comment: \"Good job Pablo!\"\r\n});\r\n\r\n// Counts items in selection.\r\ndb.select('comment').count(); // 1\r\n\r\nvar picasso = db.pid.remove(0);\r\ndb.size(); // (0)\r\n\r\n// Get all available keys in the index\r\ndb.painter.getAllKeys(); // ['0','1', ... ]\r\n\r\n// Get all elements indexed by their key in one object\r\ndb.painter.getAllKeyElements();\r\n```\r\n\r\n## Example of a configuration object\r\n\r\n```javascript\r\nvar logFunc = function(txt, level) {\r\n if (level > 0) {\r\n console.log(txt);\r\n }\r\n};\r\n\r\nvar options = {\r\n tags: {}, // Collection of tags\r\n update: { // On every insert, remove and update:\r\n indexes: true, // Updates the indexes, if any\r\n sort: true, // Sorts the items of the database\r\n pointer: true, // Moves the iterator to the last inserted element\r\n },\r\n C: {}, // Collection of comparator functions\r\n H: {}, // Collection of hashing functions\r\n I: {}, // Collection of indexing functions\r\n V: {}, // Collection of view functions\r\n log: logFunc, // Default stdout\r\n logCtx: logCtx // The context of execution for the log function\r\n nddb_pointer: 4, // Set the pointer to element of index 4\r\n globalCompare: function(o1, o2) {\r\n // comparing code\r\n },\r\n filters: { // Extends NDDB with new operators for select queries\r\n '%': function(d, value, comparator){\r\n return function(elem) {\r\n if ((elem[d] % value) === 0) {\r\n return elem;\r\n }\r\n }\r\n },\r\n share: { // Contains objects that are copied by reference to\r\n // in every new instance of NDDB.\r\n sharedObj: sharedObj\r\n }\r\n}\r\n\r\nvar nddb = new NDDB(options);\r\n\r\n// or\r\n\r\nnddb = new NDDB();\r\nnddb.init(options);\r\n```\r\n\r\n\r\n## Saving and Loading Items\r\n\r\n\r\nThe items in the database can be saved and loaded using the `save` and\r\n`load` methods, and their synchronous implementations `saveSync` and\r\n`loadSync`.\r\n\r\n### Saving and loading to file system (node.js environment)\r\n\r\nTwo formats are natively supported: `.json` and `.csv`, and they are\r\ndetected by the extension of the filename. If a differ extension is\r\nfound, NDDB will fall back to the default format (usually json).\r\n\r\nIt is possible to specify new formats using the `addFormat` method.\r\n\r\n#### Code Examples\r\n\r\n```javascript\r\n// Saving items in JSON format.\r\ndb.save('db.json', function() {\r\n console.log(\"Saved db into 'db.json'\");\r\n});\r\n\r\n// Saving items in CSV format.\r\ndb.save('db.csv', function() {\r\n console.log(\"Saved db into db.csv'\");\r\n});\r\n\r\n// Saving items synchronously in CSV format.\r\ndb.saveSync('db.csv');\r\nconsole.log(\"Saved db into db.csv'\");\r\n\r\n// Saving items in the default format (usually json).\r\ndb.getDefaultFormat(); // json\r\ndb.save('db.out', function() {\r\n console.log(\"Saved db into db.out'\");\r\n});\r\n\r\n// Specifying the default format and saving into CSV.\r\ndb.setDefaultFormat('csv');\r\ndb.save('db.out', function() {\r\n console.log(\"Saved db into db.out'\");\r\n});\r\n\r\n// Transform items before saving them to CSV format.\r\n// Define adapter function that doubles all numbers in column \"A\".\r\nvar options = {};\r\noptions.adapter = {\r\n A: function(item) { return item.A * 2; }\r\n};\r\ndb.save('db2.csv', options, function() {\r\n console.log(\"Saved db as csv into 'db2.csv', where numbers in column 'A'\" +\r\n \"were doubled\");\r\n});\r\n\r\n\r\n// Loading items into database.\r\ndb.load('db.csv', function() {\r\n console.log(\"Loaded csv file into database\");\r\n});\r\n\r\n// Loading items into database synchronously.\r\ndb.loadSync('db.csv');\r\nconsole.log(\"Loaded csv file into database\");\r\n\r\n// Loading 'adapted' items into database.\r\ndb.load('db2.csv', function() {\r\n console.log(\"Loaded csv file into database\");\r\n});\r\n\r\n// Transform items before loading them into database.\r\n// Loading items into database.\r\nvar options = {};\r\noptions.adapter = {\r\n A: function(item) { return item.A / 2; }\r\n};\r\n\r\ndb.load('db2.csv', function() {\r\n console.log(\"Loaded csv file into database\");\r\n});\r\n\r\n// Specify a new format.\r\ndb.addFormat('asd', {\r\n save: function(db, file, cb, options) {\r\n // save file asynchronously.\r\n },\r\n load: function(db, file, cb, options) {\r\n // load file asynchronously.\r\n },\r\n saveSync: function(db, file, cb, options) {\r\n // save file synchronously.\r\n },\r\n loadSync: function(db, file, cb, options) {\r\n // load file synchronously.\r\n }\r\n});\r\n\r\n// Saving in the new format.\r\ndb.save('db.asd');\r\n```\r\n\r\n\r\n#### List of all available options\r\n\r\n```javascript\r\n{\r\n\r\n flags: 'w', // The Node.js flag to write to fs.\r\n // Default: 'a' (append).\r\n\r\n encoding: 'utf-8', // The encoding of the file.\r\n\r\n mode: 0777, // The permission given to the file.\r\n // Default: 0666\r\n\r\n // Options below are processed when the CSV format is detected.\r\n\r\n headers: true, // if options.headers === true: use\r\n // first line of file as headers;\r\n // if !options.headers: use\r\n // ['X1'...'XN'] as headers;\r\n // if options.headers is an array of\r\n // strings use it as headers;\r\n // if options.headers is an array\r\n // containing true/false use entry\r\n // from file/'Xi' respectively;\r\n\r\n\r\n adapter: { A: function(row) { // An obj containing callbacks for\r\n return row['A']-1; // each header. The callbacks take\r\n } // an object of strings and\r\n }, // return a string. Each entry in\r\n // the file is the result of\r\n // applying the callback of its\r\n // column to its row.\r\n\r\n\r\n separator: ',', // The character used as separator\r\n // between values. Default ','.\r\n\r\n quote: '\"', // The character used as quote.\r\n // Default: '\"'.\r\n\r\n commentchar: '', // The character used for comments.\r\n // Default: ''.\r\n\r\n nestedQuotes: false, // TRUE, if nested quotes allowed.\r\n // Default FALSE.\r\n\r\n escapeCharacter: '\\\\', // The char that should be skipped.\r\n // Default: \\.\r\n}\r\n```\r\n\r\n### Saving and loading to the local storage (browser environment)\r\n\r\nItems persistance in the browser is available only if NDDB is built\r\nwith the [Shelf.js](https://github.com/shakty/shelf.js)\r\nextension. Alternatively, a custom `store` function taking as input\r\nthe name of the local database could be defined.\r\n\r\nAll items will be saved in the JSON format.\r\n\r\nNotice that there exist limitations to maximum number of items that\r\ncan be saved, depending on the local storage maximum capacity settings\r\nof the browser. If the limit is reached an error will be thrown.\r\n\r\n\r\n## Test\r\n\r\nNDDB relies on [mocha](http://visionmedia.github.com/mocha/) and\r\n[should.js](http://github.com/visionmedia/should.js) for testing.\r\n\r\n $ npm install # will load all necessary dependencies\r\n $ npm test # will run the test suite against nddb.js\r\n\r\n## Build\r\n\r\nCreate your customized build of NDDB using the make file in the `bin`\r\ndirectory:\r\n\r\n\r\nIn order to run in the browser NDDB needs to have\r\n[JSUS](http://github.com/nodeGame/JSUS) loaded. You can include it\r\nseparately, or create a new build that includes it already. See the\r\nbuild help for options.\r\n\r\n```javascript\r\nnode make.nddb.js build // Standard build,\r\nnode make.nddb.js build -a -o nddb-full // Full build\r\n```\r\n\r\nThe build file file will be created inside the `build/` directory.\r\n\r\n\r\n### Help\r\n\r\n```javascript\r\nnode make.nddb.js --help\r\n```\r\n\r\n## API Documentation\r\n\r\nCreate html API documentation using the make file in the bin directory:\r\n\r\n```javascript\r\nnode make.nddb.js doc\r\n```\r\n\r\n## License\r\n\r\n[MIT](LICENSE)\r\n","google":"UA-34089835-1","note":"Don't delete this file! It's used internally to help with page regeneration."}
View
116 stylesheets/github-light.css
@@ -0,0 +1,116 @@
+/*
+ Copyright 2014 GitHub Inc.
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+
+*/
+
+.pl-c /* comment */ {
+ color: #969896;
+}
+
+.pl-c1 /* constant, markup.raw, meta.diff.header, meta.module-reference, meta.property-name, support, support.constant, support.variable, variable.other.constant */,
+.pl-s .pl-v /* string variable */ {
+ color: #0086b3;
+}
+
+.pl-e /* entity */,
+.pl-en /* entity.name */ {
+ color: #795da3;
+}
+
+.pl-s .pl-s1 /* string source */,
+.pl-smi /* storage.modifier.import, storage.modifier.package, storage.type.java, variable.other, variable.parameter.function */ {
+ color: #333;
+}
+
+.pl-ent /* entity.name.tag */ {
+ color: #63a35c;
+}
+
+.pl-k /* keyword, storage, storage.type */ {
+ color: #a71d5d;
+}
+
+.pl-pds /* punctuation.definition.string, string.regexp.character-class */,
+.pl-s /* string */,
+.pl-s .pl-pse .pl-s1 /* string punctuation.section.embedded source */,
+.pl-sr /* string.regexp */,
+.pl-sr .pl-cce /* string.regexp constant.character.escape */,
+.pl-sr .pl-sra /* string.regexp string.regexp.arbitrary-repitition */,
+.pl-sr .pl-sre /* string.regexp source.ruby.embedded */ {
+ color: #183691;
+}
+
+.pl-v /* variable */ {
+ color: #ed6a43;
+}
+
+.pl-id /* invalid.deprecated */ {
+ color: #b52a1d;
+}
+
+.pl-ii /* invalid.illegal */ {
+ background-color: #b52a1d;
+ color: #f8f8f8;
+}
+
+.pl-sr .pl-cce /* string.regexp constant.character.escape */ {
+ color: #63a35c;
+ font-weight: bold;
+}
+
+.pl-ml /* markup.list */ {
+ color: #693a17;
+}
+
+.pl-mh /* markup.heading */,
+.pl-mh .pl-en /* markup.heading entity.name */,
+.pl-ms /* meta.separator */ {
+ color: #1d3e81;
+ font-weight: bold;
+}
+
+.pl-mq /* markup.quote */ {
+ color: #008080;
+}
+
+.pl-mi /* markup.italic */ {
+ color: #333;
+ font-style: italic;
+}
+
+.pl-mb /* markup.bold */ {
+ color: #333;
+ font-weight: bold;
+}
+
+.pl-md /* markup.deleted, meta.diff.header.from-file */ {
+ background-color: #ffecec;
+ color: #bd2c00;
+}
+
+.pl-mi1 /* markup.inserted, meta.diff.header.to-file */ {
+ background-color: #eaffea;
+ color: #55a532;
+}
+
+.pl-mdr /* meta.diff.range */ {
+ color: #795da3;
+ font-weight: bold;
+}
+
+.pl-mo /* meta.output */ {
+ color: #1d3e81;
+}
+
View
424 stylesheets/normalize.css
@@ -0,0 +1,424 @@
+/*! normalize.css v3.0.2 | MIT License | git.io/normalize */
+
+/**
+ * 1. Set default font family to sans-serif.
+ * 2. Prevent iOS text size adjust after orientation change, without disabling
+ * user zoom.
+ */
+
+html {
+ font-family: sans-serif; /* 1 */
+ -ms-text-size-adjust: 100%; /* 2 */
+ -webkit-text-size-adjust: 100%; /* 2 */
+}
+
+/**
+ * Remove default margin.
+ */
+
+body {
+ margin: 0;
+}
+
+/* HTML5 display definitions
+ ========================================================================== */
+
+/**
+ * Correct `block` display not defined for any HTML5 element in IE 8/9.
+ * Correct `block` display not defined for `details` or `summary` in IE 10/11
+ * and Firefox.
+ * Correct `block` display not defined for `main` in IE 11.
+ */
+
+article,
+aside,
+details,
+figcaption,
+figure,
+footer,
+header,
+hgroup,
+main,
+menu,
+nav,
+section,
+summary {
+ display: block;
+}
+
+/**
+ * 1. Correct `inline-block` display not defined in IE 8/9.
+ * 2. Normalize vertical alignment of `progress` in Chrome, Firefox, and Opera.
+ */
+
+audio,
+canvas,
+progress,
+video {
+ display: inline-block; /* 1 */
+ vertical-align: baseline; /* 2 */
+}
+
+/**
+ * Prevent modern browsers from displaying `audio` without controls.
+ * Remove excess height in iOS 5 devices.
+ */
+
+audio:not([controls]) {
+ display: none;
+ height: 0;
+}
+
+/**
+ * Address `[hidden]` styling not present in IE 8/9/10.
+ * Hide the `template` element in IE 8/9/11, Safari, and Firefox < 22.
+ */
+
+[hidden],
+template {
+ display: none;
+}
+
+/* Links
+ ========================================================================== */
+
+/**
+ * Remove the gray background color from active links in IE 10.
+ */
+
+a {
+ background-color: transparent;
+}
+
+/**
+ * Improve readability when focused and also mouse hovered in all browsers.
+ */
+
+a:active,
+a:hover {
+ outline: 0;
+}
+
+/* Text-level semantics
+ ========================================================================== */
+
+/**
+ * Address styling not present in IE 8/9/10/11, Safari, and Chrome.
+ */
+
+abbr[title] {
+ border-bottom: 1px dotted;
+}
+
+/**
+ * Address style set to `bolder` in Firefox 4+, Safari, and Chrome.
+ */
+
+b,
+strong {
+ font-weight: bold;
+}
+
+/**
+ * Address styling not present in Safari and Chrome.
+ */
+
+dfn {
+ font-style: italic;
+}
+
+/**
+ * Address variable `h1` font-size and margin within `section` and `article`
+ * contexts in Firefox 4+, Safari, and Chrome.
+ */
+
+h1 {
+ font-size: 2em;
+ margin: 0.67em 0;
+}
+
+/**
+ * Address styling not present in IE 8/9.
+ */
+
+mark {
+ background: #ff0;
+ color: #000;
+}
+
+/**
+ * Address inconsistent and variable font size in all browsers.
+ */
+
+small {
+ font-size: 80%;
+}
+
+/**
+ * Prevent `sub` and `sup` affecting `line-height` in all browsers.
+ */
+
+sub,
+sup {
+ font-size: 75%;
+ line-height: 0;
+ position: relative;
+ vertical-align: baseline;
+}
+
+sup {
+ top: -0.5em;
+}
+
+sub {
+ bottom: -0.25em;
+}
+
+/* Embedded content
+ ========================================================================== */
+
+/**
+ * Remove border when inside `a` element in IE 8/9/10.
+ */
+
+img {
+ border: 0;
+}
+
+/**
+ * Correct overflow not hidden in IE 9/10/11.
+ */
+
+svg:not(:root) {
+ overflow: hidden;
+}
+
+/* Grouping content
+ ========================================================================== */
+
+/**
+ * Address margin not present in IE 8/9 and Safari.
+ */
+
+figure {
+ margin: 1em 40px;
+}
+
+/**
+ * Address differences between Firefox and other browsers.
+ */
+
+hr {
+ box-sizing: content-box;
+ height: 0;
+}
+
+/**
+ * Contain overflow in all browsers.
+ */
+
+pre {
+ overflow: auto;
+}
+
+/**
+ * Address odd `em`-unit font size rendering in all browsers.
+ */
+
+code,
+kbd,
+pre,
+samp {
+ font-family: monospace, monospace;
+ font-size: 1em;
+}
+
+/* Forms
+ ========================================================================== */
+
+/**
+ * Known limitation: by default, Chrome and Safari on OS X allow very limited
+ * styling of `select`, unless a `border` property is set.
+ */
+
+/**
+ * 1. Correct color not being inherited.
+ * Known issue: affects color of disabled elements.
+ * 2. Correct font properties not being inherited.
+ * 3. Address margins set differently in Firefox 4+, Safari, and Chrome.
+ */
+
+button,
+input,
+optgroup,
+select,
+textarea {
+ color: inherit; /* 1 */
+ font: inherit; /* 2 */
+ margin: 0; /* 3 */
+}
+
+/**
+ * Address `overflow` set to `hidden` in IE 8/9/10/11.
+ */
+
+button {
+ overflow: visible;
+}
+
+/**
+ * Address inconsistent `text-transform` inheritance for `button` and `select`.
+ * All other form control elements do not inherit `text-transform` values.
+ * Correct `button` style inheritance in Firefox, IE 8/9/10/11, and Opera.
+ * Correct `select` style inheritance in Firefox.
+ */
+
+button,
+select {
+ text-transform: none;
+}
+
+/**
+ * 1. Avoid the WebKit bug in Android 4.0.* where (2) destroys native `audio`
+ * and `video` controls.
+ * 2. Correct inability to style clickable `input` types in iOS.
+ * 3. Improve usability and consistency of cursor style between image-type
+ * `input` and others.
+ */
+
+button,
+html input[type="button"], /* 1 */
+input[type="reset"],
+input[type="submit"] {
+ -webkit-appearance: button; /* 2 */
+ cursor: pointer; /* 3 */
+}
+
+/**
+ * Re-set default cursor for disabled elements.
+ */
+
+button[disabled],
+html input[disabled] {
+ cursor: default;
+}
+
+/**
+ * Remove inner padding and border in Firefox 4+.
+ */
+
+button::-moz-focus-inner,
+input::-moz-focus-inner {
+ border: 0;
+ padding: 0;
+}
+
+/**
+ * Address Firefox 4+ setting `line-height` on `input` using `!important` in
+ * the UA stylesheet.
+ */
+
+input {
+ line-height: normal;
+}
+
+/**
+ * It's recommended that you don't attempt to style these elements.
+ * Firefox's implementation doesn't respect box-sizing, padding, or width.
+ *
+ * 1. Address box sizing set to `content-box` in IE 8/9/10.
+ * 2. Remove excess padding in IE 8/9/10.
+ */
+
+input[type="checkbox"],
+input[type="radio"] {
+ box-sizing: border-box; /* 1 */
+ padding: 0; /* 2 */
+}
+
+/**
+ * Fix the cursor style for Chrome's increment/decrement buttons. For certain
+ * `font-size` values of the `input`, it causes the cursor style of the
+ * decrement button to change from `default` to `text`.
+ */
+
+input[type="number"]::-webkit-inner-spin-button,
+input[type="number"]::-webkit-outer-spin-button {
+ height: auto;
+}
+
+/**
+ * 1. Address `appearance` set to `searchfield` in Safari and Chrome.
+ * 2. Address `box-sizing` set to `border-box` in Safari and Chrome
+ * (include `-moz` to future-proof).
+ */
+
+input[type="search"] {
+ -webkit-appearance: textfield; /* 1 */ /* 2 */
+ box-sizing: content-box;
+}
+
+/**
+ * Remove inner padding and search cancel button in Safari and Chrome on OS X.
+ * Safari (but not Chrome) clips the cancel button when the search input has
+ * padding (and `textfield` appearance).
+ */
+
+input[type="search"]::-webkit-search-cancel-button,
+input[type="search"]::-webkit-search-decoration {
+ -webkit-appearance: none;
+}
+
+/**
+ * Define consistent border, margin, and padding.
+ */
+
+fieldset {
+ border: 1px solid #c0c0c0;
+ margin: 0 2px;
+ padding: 0.35em 0.625em 0.75em;
+}
+
+/**
+ * 1. Correct `color` not being inherited in IE 8/9/10/11.
+ * 2. Remove padding so people aren't caught out if they zero out fieldsets.
+ */
+
+legend {
+ border: 0; /* 1 */
+ padding: 0; /* 2 */
+}
+
+/**
+ * Remove default vertical scrollbar in IE 8/9/10/11.
+ */
+
+textarea {
+ overflow: auto;
+}
+
+/**
+ * Don't inherit the `font-weight` (applied by a rule above).
+ * NOTE: the default cannot safely be changed in Chrome and Safari on OS X.
+ */
+
+optgroup {
+ font-weight: bold;
+}
+
+/* Tables
+ ========================================================================== */
+
+/**
+ * Remove most spacing between table cells.
+ */
+
+table {
+ border-collapse: collapse;
+ border-spacing: 0;
+}
+
+td,
+th {
+ padding: 0;
+}
View
676 stylesheets/stylesheet.css
@@ -1,479 +1,245 @@
-/* http://meyerweb.com/eric/tools/css/reset/
- v2.0 | 20110126
- License: none (public domain)
-*/
-html, body, div, span, applet, object, iframe,
-h1, h2, h3, h4, h5, h6, p, blockquote, pre,
-a, abbr, acronym, address, big, cite, code,
-del, dfn, em, img, ins, kbd, q, s, samp,
-small, strike, strong, sub, sup, tt, var,
-b, u, i, center,
-dl, dt, dd, ol, ul, li,
-fieldset, form, label, legend,
-table, caption, tbody, tfoot, thead, tr, th, td,
-article, aside, canvas, details, embed,
-figure, figcaption, footer, header, hgroup,
-menu, nav, output, ruby, section, summary,
-time, mark, audio, video {
- margin: 0;
- padding: 0;
- border: 0;
- font-size: 100%;
- font: inherit;
- vertical-align: baseline;
-}
-/* HTML5 display-role reset for older browsers */
-article, aside, details, figcaption, figure,
-footer, header, hgroup, menu, nav, section {
- display: block;
-}
-body {
- line-height: 1;
-}
-ol, ul {
- list-style: none;
-}
-blockquote, q {
- quotes: none;
-}
-blockquote:before, blockquote:after,
-q:before, q:after {
- content: '';
- content: none;
-}
-table {
- border-collapse: collapse;
- border-spacing: 0;
-}
+* {
+ box-sizing: border-box; }
-/* LAYOUT STYLES */
body {
- font-size: 15px;
- line-height: 1.5;
- background: #fafafa url(../images/body-bg.jpg) 0 0 repeat;
- font-family: 'Helvetica Neue', Helvetica, Arial, serif;
- font-weight: 400;
- color: #666;
-}
+ padding: 0;
+ margin: 0;
+ font-family: "Open Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
+ font-size: 16px;
+ line-height: 1.5;
+ color: #606c71; }
a {
- color: #2879d0;
-}
-a:hover {
- color: #2268b2;
-}
-
-header {
- padding-top: 40px;
- padding-bottom: 40px;
- font-family: 'Architects Daughter', 'Helvetica Neue', Helvetica, Arial, serif;
- background: #2e7bcf url(../images/header-bg.jpg) 0 0 repeat-x;
- border-bottom: solid 1px #275da1;
-}
-
-header h1 {
- letter-spacing: -1px;
- font-size: 72px;
- color: #fff;
- line-height: 1;
- margin-bottom: 0.2em;
- width: 540px;
-}
+ color: #1e6bb8;
+ text-decoration: none; }
+ a:hover {
+ text-decoration: underline; }
+
+.btn {
+ display: inline-block;
+ margin-bottom: 1rem;
+ color: rgba(255, 255, 255, 0.7);
+ background-color: rgba(255, 255, 255, 0.08);
+ border-color: rgba(255, 255, 255, 0.2);
+ border-style: solid;
+ border-width: 1px;
+ border-radius: 0.3rem;
+ transition: color 0.2s, background-color 0.2s, border-color 0.2s; }
+ .btn + .btn {
+ margin-left: 1rem; }
+
+.btn:hover {
+ color: rgba(255, 255, 255, 0.8);
+ text-decoration: none;
+ background-color: rgba(255, 255, 255, 0.2);
+ border-color: rgba(255, 255, 255, 0.3); }
-header h2 {
- font-size: 26px;
- color: #9ddcff;
- font-weight: normal;
- line-height: 1.3;
- width: 540px;
- letter-spacing: 0;
-}
+@media screen and (min-width: 64em) {
+ .btn {
+ padding: 0.75rem 1rem; } }
-.inner {
- position: relative;
- width: 940px;
- margin: 0 auto;
-}
+@media screen and (min-width: 42em) and (max-width: 64em) {
+ .btn {
+ padding: 0.6rem 0.9rem;
+ font-size: 0.9rem; } }
-#content-wrapper {
- border-top: solid 1px #fff;
- padding-top: 30px;
-}
+@media screen and (max-width: 42em) {
+ .btn {
+ display: block;
+ width: 100%;
+ padding: 0.75rem;
+ font-size: 0.9rem; }
+ .btn + .btn {
+ margin-top: 1rem;
+ margin-left: 0; } }
-#main-content {
- width: 690px;
- float: left;
-}
+.page-header {
+ color: #fff;
+ text-align: center;
+ background-color: #159957;
+ background-image: linear-gradient(120deg, #155799, #159957); }
-#main-content img {
- max-width: 100%;
-}
+@media screen and (min-width: 64em) {
+ .page-header {
+ padding: 5rem 6rem; } }
-aside#sidebar {
- width: 200px;
- padding-left: 20px;
- min-height: 504px;
- float: right;
- background: transparent url(../images/sidebar-bg.jpg) 0 0 no-repeat;
- font-size: 12px;
- line-height: 1.3;
-}
+@media screen and (min-width: 42em) and (max-width: 64em) {
+ .page-header {
+ padding: 3rem 4rem; } }
-aside#sidebar p.repo-owner,
-aside#sidebar p.repo-owner a {
- font-weight: bold;
-}
+@media screen and (max-width: 42em) {
+ .page-header {
+ padding: 2rem 1rem; } }
-#downloads {
- margin-bottom: 40px;
-}
+.project-name {
+ margin-top: 0;
+ margin-bottom: 0.1rem; }
-a.button {
- width: 134px;
- height: 58px;
- line-height: 1.2;
- font-size: 23px;
- color: #fff;
- padding-left: 68px;
- padding-top: 22px;
- font-family: 'Architects Daughter', 'Helvetica Neue', Helvetica, Arial, serif;
-}
-a.button small {
- display: block;
- font-size: 11px;
-}
-header a.button {
- position: absolute;
- right: 0;
- top: 0;
- background: transparent url(../images/github-button.png) 0 0 no-repeat;
-}
-aside a.button {
- width: 138px;
- padding-left: 64px;
- display: block;
- background: transparent url(../images/download-button.png) 0 0 no-repeat;
- margin-bottom: 20px;
- font-size: 21px;
-}
+@media screen and (min-width: 64em) {
+ .project-name {
+ font-size: 3.25rem; } }
-code, pre {
- font-family: Monaco, "Bitstream Vera Sans Mono", "Lucida Console", Terminal, monospace;
- color: #222;
- margin-bottom: 30px;
- font-size: 13px;
-}
+@media screen and (min-width: 42em) and (max-width: 64em) {
+ .project-name {
+ font-size: 2.25rem; } }
-code {
- background-color: #f2f8fc;
- border: solid 1px #dbe7f3;
- padding: 0 3px;
-}
+@media screen and (max-width: 42em) {
+ .project-name {
+ font-size: 1.75rem; } }
-pre {
- padding: 20px;
- background: #fff;
- text-shadow: none;
+.project-tagline {
+ margin-bottom: 2rem;
+ font-weight: normal;
+ opacity: 0.7; }
+
+@media screen and (min-width: 64em) {
+ .project-tagline {
+ font-size: 1.25rem; } }
+
+@media screen and (min-width: 42em) and (max-width: 64em) {
+ .project-tagline {
+ font-size: 1.15rem; } }
+
+@media screen and (max-width: 42em) {
+ .project-tagline {
+ font-size: 1rem; } }
+
+.main-content :first-child {
+ margin-top: 0; }
+.main-content img {
+ max-width: 100%; }
+.main-content h1, .main-content h2, .main-content h3, .main-content h4, .main-content h5, .main-content h6 {
+ margin-top: 2rem;
+ margin-bottom: 1rem;
+ font-weight: normal;
+ color: #159957; }
+.main-content p {
+ margin-bottom: 1em; }
+.main-content code {
+ padding: 2px 4px;
+ font-family: Consolas, "Liberation Mono", Menlo, Courier, monospace;
+ font-size: 0.9rem;
+ color: #383e41;
+ background-color: #f3f6fa;
+ border-radius: 0.3rem; }
+.main-content pre {
+ padding: 0.8rem;
+ margin-top: 0;
+ margin-bottom: 1rem;
+ font: 1rem Consolas, "Liberation Mono", Menlo, Courier, monospace;
+ color: #567482;
+ word-wrap: normal;
+ background-color: #f3f6fa;
+ border: solid 1px #dce6f0;
+ border-radius: 0.3rem; }
+ .main-content pre > code {
+ padding: 0;
+ margin: 0;
+ font-size: 0.9rem;
+ color: #567482;
+ word-break: normal;
+ white-space: pre;
+ background: transparent;
+ border: 0; }
+.main-content .highlight {
+ margin-bottom: 1rem; }
+ .main-content .highlight pre {
+ margin-bottom: 0;
+ word-break: normal; }
+.main-content .highlight pre, .main-content pre {
+ padding: 0.8rem;
overflow: auto;
- border: solid 1px #f2f2f2;
-}
-pre code {
- color: #2879d0;
- background-color: #fff;
- border: none;
+ font-size: 0.9rem;
+ line-height: 1.45;
+ border-radius: 0.3rem; }
+.main-content pre code, .main-content pre tt {
+ display: inline;
+ max-width: initial;
padding: 0;
-}
-
-ul, ol, dl {
- margin-bottom: 20px;
-}
-
-
-/* COMMON STYLES */
-
-hr {
- height: 1px;
- line-height: 1px;
- margin-top: 1em;
- padding-bottom: 1em;
- border: none;
- background: transparent url('../images/hr.png') 0 0 no-repeat;
-}
-
-table {
+ margin: 0;
+ overflow: initial;
+ line-height: inherit;
+ word-wrap: normal;
+ background-color: transparent;
+ border: 0; }
+ .main-content pre code:before, .main-content pre code:after, .main-content pre tt:before, .main-content pre tt:after {
+ content: normal; }
+.main-content ul, .main-content ol {
+ margin-top: 0; }
+.main-content blockquote {
+ padding: 0 1rem;
+ margin-left: 0;
+ color: #819198;
+ border-left: 0.3rem solid #dce6f0; }
+ .main-content blockquote > :first-child {
+ margin-top: 0; }
+ .main-content blockquote > :last-child {
+ margin-bottom: 0; }
+.main-content table {
+ display: block;
width: 100%;
- border: 1px solid #ebebeb;
-}
-
-th {
- font-weight: 500;
-}
-
-td {
- border: 1px solid #ebebeb;
- text-align: center;
- font-weight: 300;
-}
-
-form {
- background: #f2f2f2;
- padding: 20px;
-
-}
-
-
-/* GENERAL ELEMENT TYPE STYLES */
-
-#main-content h1 {
- font-family: 'Architects Daughter', 'Helvetica Neue', Helvetica, Arial, serif;
- font-size: 2.8em;
- letter-spacing: -1px;
- color: #474747;
-}
-
-#main-content h1:before {
- content: "/";
- color: #9ddcff;
- padding-right: 0.3em;
- margin-left: -0.9em;
-}
-
-#main-content h2 {
- font-family: 'Architects Daughter', 'Helvetica Neue', Helvetica, Arial, serif;
- font-size: 22px;
- font-weight: bold;
- margin-bottom: 8px;
- color: #474747;
-}
-#main-content h2:before {
- content: "//";
- color: #9ddcff;
- padding-right: 0.3em;
- margin-left: -1.5em;
-}
-
-#main-content h3 {
- font-family: 'Architects Daughter', 'Helvetica Neue', Helvetica, Arial, serif;
- font-size: 18px;
- font-weight: bold;
- margin-top: 24px;
- margin-bottom: 8px;
- color: #474747;
-}
-
-#main-content h3:before {
- content: "///";
- color: #9ddcff;
- padding-right: 0.3em;
- margin-left: -2em;
-}
-
-#main-content h4 {
- font-family: 'Architects Daughter', 'Helvetica Neue', Helvetica, Arial, serif;
- font-size: 15px;
- font-weight: bold;
- color: #474747;
-}
-
-h4:before {
- content: "////";
- color: #9ddcff;
- padding-right: 0.3em;
- margin-left: -2.8em;
-}
-
-#main-content h5 {
- font-family: 'Architects Daughter', 'Helvetica Neue', Helvetica, Arial, serif;
- font-size: 14px;
- color: #474747;
-}
-h5:before {
- content: "/////";
- color: #9ddcff;
- padding-right: 0.3em;
- margin-left: -3.2em;
-}
-
-#main-content h6 {
- font-family: 'Architects Daughter', 'Helvetica Neue', Helvetica, Arial, serif;
- font-size: .8em;
- color: #474747;
-}
-h6:before {
- content: "//////";
- color: #9ddcff;
- padding-right: 0.3em;
- margin-left: -3.7em;
-}
-
-p {
- margin-bottom: 20px;
-}
-
-a {
- text-decoration: none;
-}
-
-p a {
- font-weight: 400;
-}
-
-blockquote {
- font-size: 1.6em;
- border-left: 10px solid #e9e9e9;
- margin-bottom: 20px;
- padding: 0 0 0 30px;
-}
-
-ul li {
- list-style: disc inside;
- padding-left: 20px;
-}
-
-ol li {
- list-style: decimal inside;
- padding-left: 3px;
-}
-
-dl dd {
- font-style: italic;
- font-weight: 100;
-}
-
-footer {
- background: transparent url('../images/hr.png') 0 0 no-repeat;
- margin-top: 40px;
- padding-top: 20px;
- padding-bottom: 30px;
- font-size: 13px;
- color: #aaa;
-}
-
-footer a {
- color: #666;
-}
-footer a:hover {
- color: #444;
-}
-
-/* MISC */
-.clearfix:after {
- clear: both;
- content: '.';
+ overflow: auto;
+ word-break: normal;
+ word-break: keep-all; }
+ .main-content table th {
+ font-weight: bold; }
+ .main-content table th, .main-content table td {
+ padding: 0.5rem 1rem;
+ border: 1px solid #e9ebec; }
+.main-content dl {
+ padding: 0; }
+ .main-content dl dt {
+ padding: 0;
+ margin-top: 1rem;
+ font-size: 1rem;
+ font-weight: bold; }
+ .main-content dl dd {
+ padding: 0;
+ margin-bottom: 1rem; }
+.main-content hr {
+ height: 2px;
+ padding: 0;
+ margin: 1rem 0;
+ background-color: #eff0f1;
+ border: 0; }
+
+@media screen and (min-width: 64em) {
+ .main-content {
+ max-width: 64rem;
+ padding: 2rem 6rem;
+ margin: 0 auto;
+ font-size: 1.1rem; } }
+
+@media screen and (min-width: 42em) and (max-width: 64em) {
+ .main-content {
+ padding: 2rem 4rem;
+ font-size: 1.1rem; } }
+
+@media screen and (max-width: 42em) {
+ .main-content {