-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdevisPattern.js
More file actions
43 lines (36 loc) · 923 Bytes
/
devisPattern.js
File metadata and controls
43 lines (36 loc) · 923 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
38
39
40
41
42
43
/* Copyright (c) 2016 Devis, MIT License */
"use strict";
const Addon = require("./build/Release/addon");
const obj = new Addon.devisPattern();
class devisPattern {
constructor() {
this.path = [];
this.id = 0;
}
add(path, handle) {
this.path[this.id] = handle;
//path = jsonSort(path);
obj.add(JSON.stringify(path), this.id);
this.id++;
return this;
}
find(path) {
//path = jsonSort(path);
let id = obj.find(JSON.stringify(path));
if (id !== -1) {return this.path[id];}
else {return null;}
}
call(path, args, callback) {
if (!callback) {
callback = args;
args = {};
}
let res = this.find(path);
if (res) {res.call(this, args, callback);}
return this;
}
list() {
return obj.list();
}
}
module.exports = devisPattern;