forked from gatapia/nclosure
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.js
More file actions
29 lines (26 loc) · 785 Bytes
/
example.js
File metadata and controls
29 lines (26 loc) · 785 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/*
* Load node-goog through Node's standard mechanism, then
* use Closure's way of importing namespaces.
*/
var goog = require( 'goog' ).goog;
goog.require( 'goog.async.Delay' );
goog.require( 'goog.structs.Trie' );
/*
* Create a delayed function which will be executed
* in 1.5 seconds.
*/
var delay = new goog.async.Delay( function() {
console.info( "Bye!" );
} ).start( 1500 );
/*
* Create a trie and insert some data.
*/
var trie = new goog.structs.Trie();
trie.add( "demo", "node-goog" );
trie.add( "ex", [ "girlfriend", "parrot" ] );
trie.add( "example", { "hello": "world" } );
/*
* A trie finds the associated data of all prefixes (of 'examples'
* in this case) in O(L), where L is the length of the key:
*/
console.info( trie.getKeyAndPrefixes( "examples" ) );