forked from brianc/node-sql
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
37 lines (31 loc) · 770 Bytes
/
index.js
File metadata and controls
37 lines (31 loc) · 770 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
30
31
32
33
34
35
36
37
'use strict';
var assert = require('assert');
var Node = function(type) {
this.nodes = [];
};
Node.prototype.toNode = function() {
return this;
};
Node.prototype.add = function(node) {
assert(node, 'Error while trying to add a non-existant node to a query');
this.nodes.push(typeof node === 'string' ? new TextNode(node) : node.toNode());
return this;
};
Node.define = function(def) {
var c = function() {
Node.apply(this, arguments);
if(def.constructor) {
def.constructor.apply(this, arguments);
}
};
var key;
for(key in Node.prototype) {
c.prototype[key] = Node.prototype[key];
}
for(key in def) {
c.prototype[key] = def[key];
}
return c;
};
module.exports = Node;
var TextNode = require(__dirname + '/text');