@buley/dash 0.0.30 → 2.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +82 -65
- package/dist/src/engine/ai.d.ts +10 -0
- package/dist/src/engine/ai.js +47 -0
- package/dist/src/engine/sqlite.d.ts +31 -0
- package/dist/src/engine/sqlite.js +239 -0
- package/dist/src/engine/vec_extension.d.ts +5 -0
- package/dist/src/engine/vec_extension.js +10 -0
- package/dist/src/index.d.ts +3 -0
- package/dist/src/index.js +3 -0
- package/dist/src/mcp/server.d.ts +8 -0
- package/dist/src/mcp/server.js +87 -0
- package/dist/src/reactivity/signal.d.ts +3 -0
- package/dist/src/reactivity/signal.js +31 -0
- package/dist/src/sync/backup.d.ts +12 -0
- package/dist/src/sync/backup.js +44 -0
- package/dist/src/sync/connection.d.ts +16 -0
- package/dist/src/sync/connection.js +29 -0
- package/dist/src/sync/provider.d.ts +11 -0
- package/dist/src/sync/provider.js +67 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +33 -31
- package/.coveralls.yml +0 -1
- package/.github/workflows/opencommit.yml +0 -33
- package/.github/workflows/testing.yml +0 -20
- package/.gitmodules +0 -0
- package/behaviors/cache.dev.js +0 -282
- package/behaviors/changes.dev.js +0 -337
- package/behaviors/collect.dev.js +0 -40
- package/behaviors/examples/async.dev.js +0 -17
- package/behaviors/firebase.dev.js +0 -283
- package/behaviors/live.dev.js +0 -67
- package/behaviors/map.dev.js +0 -54
- package/behaviors/mapreduce.dev.js +0 -68
- package/behaviors/match.dev.js +0 -66
- package/behaviors/patch.dev.js +0 -69
- package/behaviors/rest.dev.js +0 -340
- package/behaviors/shorthand.dev.js +0 -59
- package/behaviors/stats.dev.js +0 -672
- package/dist/behaviors/index.js +0 -142
- package/dist/database/index.js +0 -76
- package/dist/databases/index.js +0 -121
- package/dist/entry/index.js +0 -166
- package/dist/index.js +0 -93
- package/dist/indexes/index.js +0 -153
- package/dist/store/index.js +0 -97
- package/dist/stores/index.js +0 -90
- package/dist/utilities/index.js +0 -174
- package/documentation/database/closing.md +0 -3
- package/documentation/database/getting.md +0 -1
- package/documentation/database/opening.md +0 -5
- package/documentation/database/removing.md +0 -3
- package/documentation/databases.md +0 -21
- package/documentation/entries.md +0 -13
- package/documentation/entry/adding.md +0 -1
- package/documentation/entry/getting.md +0 -4
- package/documentation/entry/putting.md +0 -0
- package/documentation/entry/removing.md +0 -3
- package/documentation/entry/updating.md +0 -0
- package/documentation/general/security.md +0 -10
- package/documentation/general/transaction/requests.md +0 -3
- package/documentation/general/transactions.md +0 -5
- package/documentation/index/creating.md +0 -1
- package/documentation/index/getting.md +0 -1
- package/documentation/index/iterating.md +0 -1
- package/documentation/index/removing.md +0 -1
- package/documentation/indexes.md +0 -3
- package/documentation/key/cursors.md +0 -5
- package/documentation/key/range/bounds.md +0 -11
- package/documentation/key/range/direction.md +0 -1
- package/documentation/key/ranges.md +0 -3
- package/documentation/keys.md +0 -12
- package/documentation/objectstore/clearing.md +0 -1
- package/documentation/objectstore/creating.md +0 -1
- package/documentation/objectstore/getting.md +0 -1
- package/documentation/objectstore/iteration.md +0 -1
- package/documentation/objectstore/removing.md +0 -1
- package/documentation/overview.md +0 -5
- package/documentation/stores.md +0 -13
- package/jest.config.js +0 -12
- package/src/behaviors/index.ts +0 -140
- package/src/database/index.ts +0 -81
- package/src/databases/index.ts +0 -127
- package/src/entry/index.ts +0 -183
- package/src/index/index.ts +0 -61
- package/src/index.ts +0 -96
- package/src/indexes/index.ts +0 -151
- package/src/store/index.ts +0 -102
- package/src/stores/index.ts +0 -90
- package/src/utilities/index.ts +0 -349
- package/tests/behaviors/behaviors.spec.ts +0 -123
- package/tests/database/database.spec.ts +0 -177
- package/tests/databases/databases.spec.ts +0 -199
- package/tests/entry/entry.spec.ts +0 -252
- package/tests/index/index.spec.ts +0 -94
- package/tests/indexes/indexes.spec.ts +0 -203
- package/tests/store/store.spec.ts +0 -164
- package/tests/stores/stores.spec.ts +0 -148
- package/tests/utilities/clone.spec.ts +0 -48
- package/tests/utilities/cloneError.spec.ts +0 -33
- package/tests/utilities/contains.spec.ts +0 -28
- package/tests/utilities/exists.spec.ts +0 -21
- package/tests/utilities/is.spec.ts +0 -37
- package/tests/utilities/isArray.spec.ts +0 -21
- package/tests/utilities/isBoolean.spec.ts +0 -23
- package/tests/utilities/isEmpty.spec.ts +0 -45
- package/tests/utilities/isFunction.spec.ts +0 -30
- package/tests/utilities/isNumber.spec.ts +0 -29
- package/tests/utilities/isObject.spec.ts +0 -42
- package/tests/utilities/isRegEx.spec.ts +0 -33
- package/tests/utilities/isString.spec.ts +0 -25
- package/tests/utilities/isnt.spec.ts +0 -50
- package/tests/utilities/randomId.spec.ts +0 -39
- package/tests/utilities/safeApply.spec.ts +0 -49
- package/tests/utilities/safeEach.spec.ts +0 -38
- package/tests/utilities/safeIterate.spec.ts +0 -47
- package/tsconfig.json +0 -16
|
@@ -1,283 +0,0 @@
|
|
|
1
|
-
var dashFirebase = (function (environment) {
|
|
2
|
-
"use strict";
|
|
3
|
-
var that,
|
|
4
|
-
child = function( context ) {
|
|
5
|
-
var deferred = that.deferred();
|
|
6
|
-
context.method = 'child';
|
|
7
|
-
return deferred.promise;
|
|
8
|
-
},
|
|
9
|
-
set = function( context ) {
|
|
10
|
-
var deferred = that.deferred(),
|
|
11
|
-
ref = firebase[ [context.firebase, context.database, context.store ].join('/') ].child(context.primary_key);
|
|
12
|
-
context.method = 'set';
|
|
13
|
-
ref.set( context.entry, function(err) {
|
|
14
|
-
if(that.err, null) {
|
|
15
|
-
deferred.resolve(context.entry);
|
|
16
|
-
} else {
|
|
17
|
-
deferred.reject(err);
|
|
18
|
-
}
|
|
19
|
-
} );
|
|
20
|
-
return deferred.promise;
|
|
21
|
-
},
|
|
22
|
-
update = function( context ) {
|
|
23
|
-
var deferred = that.deferred(),
|
|
24
|
-
ref = firebase[ [context.firebase, context.database, context.store ].join('/') ].child(context.primary_key);
|
|
25
|
-
context.method = 'update';
|
|
26
|
-
ref.update(context.entry, function() {
|
|
27
|
-
if(that.err, null) {
|
|
28
|
-
deferred.resolve(context.entry);
|
|
29
|
-
} else {
|
|
30
|
-
deferred.reject(err);
|
|
31
|
-
}
|
|
32
|
-
});
|
|
33
|
-
return deferred.promise;
|
|
34
|
-
},
|
|
35
|
-
remove = function( context ) {
|
|
36
|
-
var deferred = that.deferred(),
|
|
37
|
-
ref = firebase[ [context.firebase, context.database, context.store ].join('/') ].child(context.primary_key);
|
|
38
|
-
context.method = 'remove';
|
|
39
|
-
ref.remove(function() {
|
|
40
|
-
if(that.err, null) {
|
|
41
|
-
deferred.resolve(context.entry);
|
|
42
|
-
} else {
|
|
43
|
-
deferred.reject(err);
|
|
44
|
-
}
|
|
45
|
-
});
|
|
46
|
-
return deferred.promise;
|
|
47
|
-
},
|
|
48
|
-
whichMethod = function(signature) {
|
|
49
|
-
if ( that.contains( [ 'get.entry', 'get.entries', 'get.index', 'get.database', 'get.store' ], signature)) {
|
|
50
|
-
return 'child';
|
|
51
|
-
} else if ( that.contains([ 'remove.entry', 'remove.entries', 'remove.index', 'remove.database', 'remove.store' ], signature)) {
|
|
52
|
-
return 'remove';
|
|
53
|
-
} else if ( that.contains([ 'add.entry' ], signature)) {
|
|
54
|
-
return 'set';
|
|
55
|
-
} else if ( that.contains([ 'update.entry', 'update.entries' ], signature)) {
|
|
56
|
-
return 'update';
|
|
57
|
-
} else {
|
|
58
|
-
return null;
|
|
59
|
-
}
|
|
60
|
-
},
|
|
61
|
-
scripts = ( !! environment.document) ? environment.document.getElementsByTagName("script") : [],
|
|
62
|
-
libraryScript = scripts[scripts.length - 1] || null,
|
|
63
|
-
libraryPath =( null !== libraryScript && null === libraryScript.src.match(/chrome-extension/) ) ? libraryScript.src : null,
|
|
64
|
-
workerEnvironment = null !== environment.constructor.toString().match(/WorkerGlobalScope/),
|
|
65
|
-
worker = !!workerEnvironment && !!libraryPath && null !== libraryPath.match(/firebase/) ? new Worker(libraryPath) : null,
|
|
66
|
-
workQueue = {},
|
|
67
|
-
firebases = {},
|
|
68
|
-
workRegister = function (worker, message, context, success, error, notify) {
|
|
69
|
-
var id = that.random(),
|
|
70
|
-
callback = function (e) {
|
|
71
|
-
var data = e.data,
|
|
72
|
-
queued = workQueue[data.uid];
|
|
73
|
-
if (undefined !== queued) {
|
|
74
|
-
switch (e.data.type) {
|
|
75
|
-
case 'success':
|
|
76
|
-
delete workQueue[data.uid];
|
|
77
|
-
worker.removeEventListener('message', callback);
|
|
78
|
-
that.apply(success, [data]);
|
|
79
|
-
break;
|
|
80
|
-
case 'error':
|
|
81
|
-
delete workQueue[data.uid];
|
|
82
|
-
worker.removeEventListener('message', callback);
|
|
83
|
-
that.apply(error, [data]);
|
|
84
|
-
break;
|
|
85
|
-
case 'abort':
|
|
86
|
-
that.apply(notify, [data]);
|
|
87
|
-
break;
|
|
88
|
-
default:
|
|
89
|
-
break;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
},
|
|
93
|
-
clean = function(obj) {
|
|
94
|
-
if (that.isFunction(obj)) {
|
|
95
|
-
return undefined;
|
|
96
|
-
} else if (that.isObject(obj)) {
|
|
97
|
-
that.iterate(obj, function(key, val) {
|
|
98
|
-
obj[ key ] = clean(val);
|
|
99
|
-
});
|
|
100
|
-
} else if (that.isArray(obj)) {
|
|
101
|
-
that.each(obj, function(v, i) {
|
|
102
|
-
obj[i] = clean(v);
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
return obj;
|
|
106
|
-
};
|
|
107
|
-
workQueue[id] = {
|
|
108
|
-
success: success,
|
|
109
|
-
error: error,
|
|
110
|
-
notify: notify
|
|
111
|
-
};
|
|
112
|
-
worker.addEventListener('message', callback);
|
|
113
|
-
worker.postMessage({
|
|
114
|
-
method: message,
|
|
115
|
-
context: clean(context),
|
|
116
|
-
uid: id
|
|
117
|
-
});
|
|
118
|
-
return id;
|
|
119
|
-
},
|
|
120
|
-
workDispatch = function (message, context) {
|
|
121
|
-
var defd = that.deferred(),
|
|
122
|
-
callbacks = {
|
|
123
|
-
on_success: context.on_success,
|
|
124
|
-
on_error: context.on_error,
|
|
125
|
-
on_abort: context.on_abort,
|
|
126
|
-
on_complete: context.on_complete,
|
|
127
|
-
on_upgrade_needed: context.on_upgrade_needed,
|
|
128
|
-
on_blocked: context.on_blocked,
|
|
129
|
-
on_close: context.on_close
|
|
130
|
-
},
|
|
131
|
-
getData = function (data) {
|
|
132
|
-
if( that.isObject(data) ) {
|
|
133
|
-
that.iterate(callbacks, function (key, val) {
|
|
134
|
-
if(!!val) {
|
|
135
|
-
data[key] = val;
|
|
136
|
-
}
|
|
137
|
-
});
|
|
138
|
-
}
|
|
139
|
-
return data;
|
|
140
|
-
};
|
|
141
|
-
that.iterate(callbacks, function (key, val) {
|
|
142
|
-
delete context[key];
|
|
143
|
-
});
|
|
144
|
-
workRegister(worker, message, context, function (data) {
|
|
145
|
-
var add_ctx = that.clone(context);
|
|
146
|
-
add_ctx.data = data.context.entry;
|
|
147
|
-
add_ctx.firebaseing = true;
|
|
148
|
-
that.api.add.entry(add_ctx)(function(added_ctx) {
|
|
149
|
-
delete added_ctx.firebaseing;
|
|
150
|
-
defd.resolve(getData(added_ctx));
|
|
151
|
-
}, function(added_ctx) {
|
|
152
|
-
delete added_ctx.firebaseing;
|
|
153
|
-
defd.reject(getData(added_ctx));
|
|
154
|
-
}, function(added_ctx) {
|
|
155
|
-
delete added_ctx.firebaseing;
|
|
156
|
-
defd.notify(getData(added_ctx));
|
|
157
|
-
})
|
|
158
|
-
}, function (data) {
|
|
159
|
-
defd.reject(getData(data));
|
|
160
|
-
}, function (data) {
|
|
161
|
-
defd.notify(getData(data));
|
|
162
|
-
});
|
|
163
|
-
return defd.promise;
|
|
164
|
-
};
|
|
165
|
-
|
|
166
|
-
if (true === workerEnvironment) {
|
|
167
|
-
importScripts('https://cdn.firebase.com/js/client/1.0.6/firebase.js');
|
|
168
|
-
console.log('firebase',Firebase);
|
|
169
|
-
environment.addEventListener('message', function (e) {
|
|
170
|
-
var input = e.data,
|
|
171
|
-
method = input.method,
|
|
172
|
-
value = input.value,
|
|
173
|
-
key = input.key,
|
|
174
|
-
context = input.context,
|
|
175
|
-
params = context.params,
|
|
176
|
-
expires = input.expires,
|
|
177
|
-
end = function (ctx) {
|
|
178
|
-
ctx.type = ctx.type || 'success';
|
|
179
|
-
environment.postMessage(ctx);
|
|
180
|
-
},
|
|
181
|
-
callback = function(sig) {
|
|
182
|
-
return function(data, error) {
|
|
183
|
-
delete input.context.callback;
|
|
184
|
-
if (!!error) {
|
|
185
|
-
input.context.error = error;
|
|
186
|
-
input.context.message = data;
|
|
187
|
-
input.type = 'error';
|
|
188
|
-
} else {
|
|
189
|
-
input.context.entry = data;
|
|
190
|
-
}
|
|
191
|
-
end(input);
|
|
192
|
-
}
|
|
193
|
-
};
|
|
194
|
-
if ( 'undefined' === typeof firebases[input.context.firebase] ) {
|
|
195
|
-
firebases[input.context.firebase] = new Firebase([context.firebase, context.database, context.store ].join('/'));
|
|
196
|
-
}
|
|
197
|
-
if (method === 'set' || method === 'update' || method === 'remove') {
|
|
198
|
-
context.callback = callback(method);
|
|
199
|
-
if ( method === 'set' ) {
|
|
200
|
-
set(context);
|
|
201
|
-
} else if ( method === 'child' ) {
|
|
202
|
-
child(context);
|
|
203
|
-
} else if ( method === 'update' ) {
|
|
204
|
-
update(context);
|
|
205
|
-
} else if ( method === 'remove' ) {
|
|
206
|
-
remove(context);
|
|
207
|
-
}
|
|
208
|
-
} else {
|
|
209
|
-
input.type = 'error';
|
|
210
|
-
end({
|
|
211
|
-
type: 'abort',
|
|
212
|
-
context: input,
|
|
213
|
-
error: 'No such method'
|
|
214
|
-
});
|
|
215
|
-
}
|
|
216
|
-
}, false);
|
|
217
|
-
} else {
|
|
218
|
-
return [ function (state) {
|
|
219
|
-
that = this;
|
|
220
|
-
if(this.isnt(state.context.firebase, true) || this.exists(state.context.firebaseing)) {
|
|
221
|
-
return state;
|
|
222
|
-
}
|
|
223
|
-
state.context.firebaseid = this.random();
|
|
224
|
-
firebase[ state.context.firebaseid ] = {
|
|
225
|
-
url: state.context.url,
|
|
226
|
-
params: state.context.params ? state.context.params : null
|
|
227
|
-
}
|
|
228
|
-
delete state.context.url;
|
|
229
|
-
delete state.context.params;
|
|
230
|
-
return state;
|
|
231
|
-
}, function (state) {
|
|
232
|
-
if(this.isnt(state.context.firebase, true) || this.exists(state.context.firebaseing)) {
|
|
233
|
-
return state;
|
|
234
|
-
}
|
|
235
|
-
var promise = state.promise,
|
|
236
|
-
outward = this.deferred(),
|
|
237
|
-
inward,
|
|
238
|
-
update = false,
|
|
239
|
-
args;
|
|
240
|
-
if (this.contains(['add.entry', 'update.entry', 'update.entries', 'remove.entry', 'remove.entries'], state.method)) {
|
|
241
|
-
if (this.contains(['notify', 'resolve'], state.type)) {
|
|
242
|
-
update = true;
|
|
243
|
-
}
|
|
244
|
-
} else {
|
|
245
|
-
if ((this.is('error', state.type) || (this.isEmpty(state.context.entry) && this.contains(['get.entry', 'get.entries'], state.method))) && (this.is(state.context.firebase, true) || this.is(state.context.fallback, true))) {
|
|
246
|
-
update = true;
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
args = firebase[ state.context.firebaseid ];
|
|
250
|
-
if (update) {
|
|
251
|
-
state.promise = outward.promise;
|
|
252
|
-
state.context.url = args.url;0
|
|
253
|
-
if (that.isFunction(state.context.url)) {
|
|
254
|
-
state.context.url = that.apply(state.context.url, [that.clone(state)]);
|
|
255
|
-
}
|
|
256
|
-
if (that.isFunction(state.context.params)) {
|
|
257
|
-
state.context.params = that.apply(state.context.params, [that.clone(state)]);
|
|
258
|
-
}
|
|
259
|
-
state.context.params = args.params;
|
|
260
|
-
inward = workDispatch( whichMethod(state.method), state.context);
|
|
261
|
-
inward(function(ctx2){
|
|
262
|
-
state.context = ctx2;
|
|
263
|
-
state.type = 'resolve';
|
|
264
|
-
outward.resolve(state.context);
|
|
265
|
-
}, function(ctx2) {
|
|
266
|
-
state.context = ctx2;
|
|
267
|
-
state.type = 'error';
|
|
268
|
-
outward.reject(state.context);
|
|
269
|
-
}, function(ctx2) {
|
|
270
|
-
state.type = 'notify';
|
|
271
|
-
state.context = ctx2;
|
|
272
|
-
outward.notify(state.context);
|
|
273
|
-
});
|
|
274
|
-
} else {
|
|
275
|
-
state.context.url = args.url;
|
|
276
|
-
state.context.params = args.params;
|
|
277
|
-
delete firebase[ state.context.firebaseid ];
|
|
278
|
-
delete state.context.firebaseid;
|
|
279
|
-
}
|
|
280
|
-
return state;
|
|
281
|
-
} ];
|
|
282
|
-
}
|
|
283
|
-
}(self));
|
package/behaviors/live.dev.js
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
var dashLive = (function (environment) {
|
|
2
|
-
"use strict";
|
|
3
|
-
var that,
|
|
4
|
-
liveMap = {},
|
|
5
|
-
live = function(ste) {
|
|
6
|
-
var ctx = ste.context,
|
|
7
|
-
fn = function(live_ctx) {
|
|
8
|
-
if (!liveMap[ ste.context.liveid ]) {
|
|
9
|
-
return live_ctx;
|
|
10
|
-
}
|
|
11
|
-
var ditto = that.clone(ste);
|
|
12
|
-
ditto.type = that.contains(['get.entries', 'update.entries', 'remove.entries'], ditto.method) ? 'notify' : 'resolve';
|
|
13
|
-
ditto.context = live_ctx.context;
|
|
14
|
-
ditto.context.zombie = 'braaains';
|
|
15
|
-
liveMap[ ste.context.liveid ][ditto.type](ditto);
|
|
16
|
-
};
|
|
17
|
-
fn.ready = false;
|
|
18
|
-
return fn;
|
|
19
|
-
};
|
|
20
|
-
return [ function (state) {
|
|
21
|
-
that = this;
|
|
22
|
-
if(this.isnt(state.context.live, true)) {
|
|
23
|
-
return state;
|
|
24
|
-
}
|
|
25
|
-
state.context.liveid = this.random();
|
|
26
|
-
var lives = live(this.clone(state));
|
|
27
|
-
liveMap[ state.context.liveid ] = lives;
|
|
28
|
-
if (this.isArray(state.context.changes)) {
|
|
29
|
-
state.context.changes.push(lives);
|
|
30
|
-
} else if (this.isFunction(state.context.changes)) {
|
|
31
|
-
state.context.changes = [state.context.changes, lives];
|
|
32
|
-
} else {
|
|
33
|
-
state.context.changes = [lives];
|
|
34
|
-
}
|
|
35
|
-
return state;
|
|
36
|
-
}, function (state) {
|
|
37
|
-
that = this;
|
|
38
|
-
if(this.isEmpty(state.context.liveid)) {
|
|
39
|
-
return state;
|
|
40
|
-
}
|
|
41
|
-
var promise = state.promise,
|
|
42
|
-
deferred = this.deferred(),
|
|
43
|
-
removeChanges = function(ste) {
|
|
44
|
-
if(that.isArray(ste.context.changes)) {
|
|
45
|
-
that.each(ste.context.changes, function(el, i) {
|
|
46
|
-
if (that.is(ste, liveMap[ ste.context.liveid ])) {
|
|
47
|
-
delete ste.context.changes[ i ];
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
delete ste.context.liveid;
|
|
52
|
-
return ste;
|
|
53
|
-
};
|
|
54
|
-
if (this.contains(['resolve', 'error'], state.type)) {
|
|
55
|
-
liveMap[ state.context.liveid ] = deferred;
|
|
56
|
-
}
|
|
57
|
-
state.promise = deferred.promise;
|
|
58
|
-
promise(function(ctx) {
|
|
59
|
-
deferred.resolve(removeChanges(ctx));
|
|
60
|
-
}, function(ctx) {
|
|
61
|
-
deferred.error(removeChanges(ctx));
|
|
62
|
-
}, function(ctx) {
|
|
63
|
-
deferred.notify(removeChanges(ctx));
|
|
64
|
-
});
|
|
65
|
-
return removeChanges(state);
|
|
66
|
-
} ];
|
|
67
|
-
}(self));
|
package/behaviors/map.dev.js
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
var dashMap = (function (environment) {
|
|
2
|
-
"use strict";
|
|
3
|
-
var mapMap = {}; //heh
|
|
4
|
-
return [ function (state) {
|
|
5
|
-
if(this.isEmpty(state.context.map) || !this.isEmpty(state.context.reduce)) {
|
|
6
|
-
return state;
|
|
7
|
-
}
|
|
8
|
-
state.context.mapid = this.random();
|
|
9
|
-
mapMap[ state.context.mapid ] = this.isArray(state.context.map) ? state.context.map : [state.context.map];
|
|
10
|
-
delete state.context.map;
|
|
11
|
-
return state;
|
|
12
|
-
}, function (state) {
|
|
13
|
-
if(this.isEmpty(state.context.mapid) || !this.isEmpty(state.context.reduce)) {
|
|
14
|
-
return state;
|
|
15
|
-
}
|
|
16
|
-
if (this.exists(state.context.entry)) {
|
|
17
|
-
var deferred = this.deferred(),
|
|
18
|
-
result = state.context.entry,
|
|
19
|
-
promise = state.promise,
|
|
20
|
-
results = [],
|
|
21
|
-
promises = [],
|
|
22
|
-
that = this;
|
|
23
|
-
this.each(mapMap[ state.context.mapid ], function(fn) {
|
|
24
|
-
result = that.apply(fn, [ result ]);
|
|
25
|
-
if (that.isFunction(result)) {
|
|
26
|
-
promises.push(result);
|
|
27
|
-
} else {
|
|
28
|
-
results.push(result);
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
if (this.isEmpty(promises)) {
|
|
32
|
-
state.context.mapped = this.is(results.length, 1) ? results[0] : results;
|
|
33
|
-
} else {
|
|
34
|
-
this.each(promises, function(pro) {
|
|
35
|
-
promise(function(result) {
|
|
36
|
-
results.push(result);
|
|
37
|
-
});
|
|
38
|
-
promise = pro;
|
|
39
|
-
});
|
|
40
|
-
state.context.promise = promise(function(ctx) {
|
|
41
|
-
ctx.mapped = that.is(results.length, 1) ? results[0] : results;
|
|
42
|
-
deferred.resolve(ctx);
|
|
43
|
-
}, function(ctx) {
|
|
44
|
-
deferred.reject(ctx);
|
|
45
|
-
}, function(ctx) {
|
|
46
|
-
deferred.notify(ctx);
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
delete mapMap[ state.context.mapid ];
|
|
50
|
-
delete state.context.mapid;
|
|
51
|
-
}
|
|
52
|
-
return state;
|
|
53
|
-
} ];
|
|
54
|
-
}(self));
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
var dashMapReduce = (function (environment) {
|
|
2
|
-
"use strict";
|
|
3
|
-
var mapReduceMap = {};
|
|
4
|
-
return [ function (state) {
|
|
5
|
-
if(this.isEmpty(state.context.map) || this.isEmpty(state.context.reduce)) {
|
|
6
|
-
return state;
|
|
7
|
-
}
|
|
8
|
-
state.context.mapReduceId = this.random();
|
|
9
|
-
mapReduceMap[ state.context.mapReduceId ] = mapReduceMap[ state.context.mapReduceId ] || {};
|
|
10
|
-
mapReduceMap[ state.context.mapReduceId ].intermediate = mapReduceMap[ state.context.mapReduceId ].intermediate || null;
|
|
11
|
-
mapReduceMap[ state.context.mapReduceId ].mappers = this.isArray(state.context.map) ? state.context.map : [state.context.map];
|
|
12
|
-
mapReduceMap[ state.context.mapReduceId ].reducers = this.isArray(state.context.reduce) ? state.context.reduce : [state.context.reduce];
|
|
13
|
-
delete state.context.mapReduce;
|
|
14
|
-
return state;
|
|
15
|
-
}, function (state) {
|
|
16
|
-
if(this.isEmpty(state.context.mapReduceId)) {
|
|
17
|
-
return state;
|
|
18
|
-
}
|
|
19
|
-
var deferred = this.deferred(),
|
|
20
|
-
result = state.context.entry,
|
|
21
|
-
promise = state.promise,
|
|
22
|
-
results = [],
|
|
23
|
-
maps = [],
|
|
24
|
-
finalized,
|
|
25
|
-
promises = [],
|
|
26
|
-
that = this;
|
|
27
|
-
if (this.is(state.type, 'notify') && this.exists(state.context.entry)) {
|
|
28
|
-
this.each(mapReduceMap[ state.context.mapReduceId ].mappers, function(mapper) {
|
|
29
|
-
result = that.apply(mapper, [ result ]);
|
|
30
|
-
if (that.isFunction(result)) {
|
|
31
|
-
promises.push(result);
|
|
32
|
-
} else {
|
|
33
|
-
maps.push(result);
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
this.each(mapReduceMap[ state.context.mapReduceId ].reducers, function(reducer) {
|
|
37
|
-
result = that.apply(reducer, [ mapReduceMap[ state.context.mapReduceId ].intermediate, result ]);
|
|
38
|
-
if (that.isFunction(result)) {
|
|
39
|
-
promises.push(result);
|
|
40
|
-
} else {
|
|
41
|
-
mapReduceMap[ state.context.mapReduceId ].intermediate = result;
|
|
42
|
-
}
|
|
43
|
-
});
|
|
44
|
-
if (this.isEmpty(promises)) {
|
|
45
|
-
state.context.mapped = maps;
|
|
46
|
-
} else {
|
|
47
|
-
this.each(promises, function(pro) {
|
|
48
|
-
promise(function(result) {
|
|
49
|
-
results.push(result);
|
|
50
|
-
});
|
|
51
|
-
promise = pro;
|
|
52
|
-
});
|
|
53
|
-
state.context.promise = promise(function(ctx) {
|
|
54
|
-
state.context = ctx;
|
|
55
|
-
delete mapReduceMap[ state.context.mapReduceId ];
|
|
56
|
-
delete state.context.mapReduceId;
|
|
57
|
-
deferred.resolve(state);
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
} else if ( this.is(state.type, 'resolve')) {
|
|
61
|
-
state.context.reduced = mapReduceMap[ state.context.mapReduceId ].intermediate;
|
|
62
|
-
}
|
|
63
|
-
if ( state.context.mapReduceId ) {
|
|
64
|
-
delete state.context.mapReduceId;
|
|
65
|
-
}
|
|
66
|
-
return state;
|
|
67
|
-
} ];
|
|
68
|
-
}(self));
|
package/behaviors/match.dev.js
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
var dashMatch = (function (environment) {
|
|
2
|
-
"use strict";
|
|
3
|
-
return [ null, function (state) {
|
|
4
|
-
if(this.isEmpty(state.context.match)) {
|
|
5
|
-
return state;
|
|
6
|
-
}
|
|
7
|
-
var promise = state.promise,
|
|
8
|
-
deferred = this.deferred(),
|
|
9
|
-
that = this,
|
|
10
|
-
reduce = function(expression, context) {
|
|
11
|
-
var maybeReduce = function(expr) {
|
|
12
|
-
if (that.isFunction(expr)) {
|
|
13
|
-
expr = that.apply(expr, [context], that);
|
|
14
|
-
}
|
|
15
|
-
if (that.isObject(expr)) {
|
|
16
|
-
that.iterate(expr, function(key, value) {
|
|
17
|
-
expr[key] = maybeReduce(value, context);
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
return expr;
|
|
21
|
-
}
|
|
22
|
-
return maybeReduce(expression, context);
|
|
23
|
-
},
|
|
24
|
-
match = function(expr, data) {
|
|
25
|
-
var matches = true;
|
|
26
|
-
if (that.isEmpty(data)) {
|
|
27
|
-
return false;
|
|
28
|
-
}
|
|
29
|
-
var ok = true, any = false;
|
|
30
|
-
that.iterate(expr, function(key, val) {
|
|
31
|
-
if ( !that.exists(data[key]) ) {
|
|
32
|
-
ok = false;
|
|
33
|
-
}
|
|
34
|
-
if ( that.isObject(val) ) {
|
|
35
|
-
ok = match(val, data[key]);
|
|
36
|
-
if ( ok ) {
|
|
37
|
-
any = true;
|
|
38
|
-
}
|
|
39
|
-
} else if ( that.isRegEx(val) ) {
|
|
40
|
-
if ( that.isnt(data[key], val) && !that.exists(data[key]) || null === data[ key ].match(val) ) {
|
|
41
|
-
ok = false;
|
|
42
|
-
} else {
|
|
43
|
-
any = true;
|
|
44
|
-
}
|
|
45
|
-
} else if ( data[key] !== val) {
|
|
46
|
-
ok = false;
|
|
47
|
-
} else {
|
|
48
|
-
any = true;
|
|
49
|
-
}
|
|
50
|
-
} );
|
|
51
|
-
return that.is(state.context.any, true) ? any : ok;
|
|
52
|
-
},
|
|
53
|
-
reduced;
|
|
54
|
-
promise(function(st) {
|
|
55
|
-
reduced = reduce(st.context.match, st.context);
|
|
56
|
-
if ( 'notify' === st.type && !match(reduced, st.context.entry) ) {
|
|
57
|
-
st.type = null;
|
|
58
|
-
deferred.reject(st);
|
|
59
|
-
} else {
|
|
60
|
-
deferred.resolve(st);
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
state.promise = deferred.promise;
|
|
64
|
-
return state;
|
|
65
|
-
} ];
|
|
66
|
-
}(self));
|
package/behaviors/patch.dev.js
DELETED
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
var dashPatch = (function (environment) {
|
|
2
|
-
"use strict";
|
|
3
|
-
//TODO: Support array of sequential patches
|
|
4
|
-
var patchMap = {};
|
|
5
|
-
return [ function (state) {
|
|
6
|
-
if(this.isEmpty(state.context.patch)) {
|
|
7
|
-
return state;
|
|
8
|
-
}
|
|
9
|
-
var outside = this.deferred(),
|
|
10
|
-
inside = this.deferred(),
|
|
11
|
-
result,
|
|
12
|
-
promise = state.promise,
|
|
13
|
-
promises = [],
|
|
14
|
-
that = this;
|
|
15
|
-
state.context.patchid = this.random();
|
|
16
|
-
patchMap[ state.context.patchid ] = this.isArray(state.context.patch) ? { before: state.context.patch[0], after: state.context.patch[1] } : { before: state.context.patch, after: state.context.patch };
|
|
17
|
-
state.promise = outside.promise;
|
|
18
|
-
result = this.apply(patchMap[ state.context.patchid ].before, [ state ]);
|
|
19
|
-
if (this.is(result.promise, state.promise)) {
|
|
20
|
-
result.promise = promise;
|
|
21
|
-
state = result;
|
|
22
|
-
} else {
|
|
23
|
-
result(function(ctx) {
|
|
24
|
-
state.context.promise = promise;
|
|
25
|
-
outside.resolve(ctx);
|
|
26
|
-
}, function(ctx) {
|
|
27
|
-
state.context.promise = promise;
|
|
28
|
-
outside.reject(ctx);
|
|
29
|
-
}, function(ctx) {
|
|
30
|
-
state.context.promise = promise;
|
|
31
|
-
outside.notify(ctx);
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
return state;
|
|
35
|
-
}, function (state) {
|
|
36
|
-
if(this.isEmpty(state.context.patchid)) {
|
|
37
|
-
return state;
|
|
38
|
-
}
|
|
39
|
-
if (!patchMap[ state.context.patchid ].after) {
|
|
40
|
-
delete state.context.patchid;
|
|
41
|
-
delete patchMap[ state.context.patchid ];
|
|
42
|
-
return state;
|
|
43
|
-
}
|
|
44
|
-
var outside = this.deferred(),
|
|
45
|
-
inside = this.deferred(),
|
|
46
|
-
result,
|
|
47
|
-
promise = state.promise,
|
|
48
|
-
promises = [],
|
|
49
|
-
that = this;
|
|
50
|
-
state.promise = inside;
|
|
51
|
-
result = this.apply(patchMap[ state.context.patchid ].after, [ state ]);
|
|
52
|
-
if (this.is(result.promise, state.promise)) {
|
|
53
|
-
result.promise = promise;
|
|
54
|
-
state = result;
|
|
55
|
-
} else {
|
|
56
|
-
state.context.promise = outside.promise;
|
|
57
|
-
result(function(ctx2) {
|
|
58
|
-
delete patchMap[ ctx2.context.patchid ];
|
|
59
|
-
delete ctx2.context.patchid;
|
|
60
|
-
outside.resolve(ctx2);
|
|
61
|
-
}, function(ctx2) {
|
|
62
|
-
outside.reject(ctx2);
|
|
63
|
-
}, function(ctx2) {
|
|
64
|
-
outside.notify(ctx2);
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
return state;
|
|
68
|
-
} ];
|
|
69
|
-
}(self));
|