@buley/dash 0.0.30
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/.coveralls.yml +1 -0
- package/.github/workflows/opencommit.yml +33 -0
- package/.github/workflows/testing.yml +20 -0
- package/.gitmodules +0 -0
- package/README.md +98 -0
- package/behaviors/cache.dev.js +282 -0
- package/behaviors/changes.dev.js +337 -0
- package/behaviors/collect.dev.js +40 -0
- package/behaviors/examples/async.dev.js +17 -0
- package/behaviors/firebase.dev.js +283 -0
- package/behaviors/live.dev.js +67 -0
- package/behaviors/map.dev.js +54 -0
- package/behaviors/mapreduce.dev.js +68 -0
- package/behaviors/match.dev.js +66 -0
- package/behaviors/patch.dev.js +69 -0
- package/behaviors/rest.dev.js +340 -0
- package/behaviors/shorthand.dev.js +59 -0
- package/behaviors/stats.dev.js +672 -0
- package/dist/behaviors/index.js +142 -0
- package/dist/database/index.js +76 -0
- package/dist/databases/index.js +121 -0
- package/dist/entry/index.js +166 -0
- package/dist/index.js +93 -0
- package/dist/indexes/index.js +153 -0
- package/dist/store/index.js +97 -0
- package/dist/stores/index.js +90 -0
- package/dist/utilities/index.js +174 -0
- package/documentation/database/closing.md +3 -0
- package/documentation/database/getting.md +1 -0
- package/documentation/database/opening.md +5 -0
- package/documentation/database/removing.md +3 -0
- package/documentation/databases.md +21 -0
- package/documentation/entries.md +13 -0
- package/documentation/entry/adding.md +1 -0
- package/documentation/entry/getting.md +4 -0
- package/documentation/entry/putting.md +0 -0
- package/documentation/entry/removing.md +3 -0
- package/documentation/entry/updating.md +0 -0
- package/documentation/general/security.md +10 -0
- package/documentation/general/transaction/requests.md +3 -0
- package/documentation/general/transactions.md +5 -0
- package/documentation/index/creating.md +1 -0
- package/documentation/index/getting.md +1 -0
- package/documentation/index/iterating.md +1 -0
- package/documentation/index/removing.md +1 -0
- package/documentation/indexes.md +3 -0
- package/documentation/key/cursors.md +5 -0
- package/documentation/key/range/bounds.md +11 -0
- package/documentation/key/range/direction.md +1 -0
- package/documentation/key/ranges.md +3 -0
- package/documentation/keys.md +12 -0
- package/documentation/objectstore/clearing.md +1 -0
- package/documentation/objectstore/creating.md +1 -0
- package/documentation/objectstore/getting.md +1 -0
- package/documentation/objectstore/iteration.md +1 -0
- package/documentation/objectstore/removing.md +1 -0
- package/documentation/overview.md +5 -0
- package/documentation/stores.md +13 -0
- package/jest.config.js +12 -0
- package/package.json +40 -0
- package/src/behaviors/index.ts +140 -0
- package/src/database/index.ts +81 -0
- package/src/databases/index.ts +127 -0
- package/src/entry/index.ts +183 -0
- package/src/index/index.ts +61 -0
- package/src/index.ts +96 -0
- package/src/indexes/index.ts +151 -0
- package/src/store/index.ts +102 -0
- package/src/stores/index.ts +90 -0
- package/src/utilities/index.ts +349 -0
- package/tests/behaviors/behaviors.spec.ts +123 -0
- package/tests/database/database.spec.ts +177 -0
- package/tests/databases/databases.spec.ts +199 -0
- package/tests/entry/entry.spec.ts +252 -0
- package/tests/index/index.spec.ts +94 -0
- package/tests/indexes/indexes.spec.ts +203 -0
- package/tests/store/store.spec.ts +164 -0
- package/tests/stores/stores.spec.ts +148 -0
- package/tests/utilities/clone.spec.ts +48 -0
- package/tests/utilities/cloneError.spec.ts +33 -0
- package/tests/utilities/contains.spec.ts +28 -0
- package/tests/utilities/exists.spec.ts +21 -0
- package/tests/utilities/is.spec.ts +37 -0
- package/tests/utilities/isArray.spec.ts +21 -0
- package/tests/utilities/isBoolean.spec.ts +23 -0
- package/tests/utilities/isEmpty.spec.ts +45 -0
- package/tests/utilities/isFunction.spec.ts +30 -0
- package/tests/utilities/isNumber.spec.ts +29 -0
- package/tests/utilities/isObject.spec.ts +42 -0
- package/tests/utilities/isRegEx.spec.ts +33 -0
- package/tests/utilities/isString.spec.ts +25 -0
- package/tests/utilities/isnt.spec.ts +50 -0
- package/tests/utilities/randomId.spec.ts +39 -0
- package/tests/utilities/safeApply.spec.ts +49 -0
- package/tests/utilities/safeEach.spec.ts +38 -0
- package/tests/utilities/safeIterate.spec.ts +47 -0
- package/tsconfig.json +16 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
var dashShorthand = (function (environment) {
|
|
2
|
+
"use strict";
|
|
3
|
+
var that,
|
|
4
|
+
reduce = function(map, expr, context, reverse) {
|
|
5
|
+
if (that.isFunction(expr)) {
|
|
6
|
+
expr = that.apply(expr, [context], that);
|
|
7
|
+
}
|
|
8
|
+
if (that.isObject(expr)) {
|
|
9
|
+
that.iterate(expr, function(key, value) {
|
|
10
|
+
if (!that.isEmpty(map[key])) {
|
|
11
|
+
delete expr[key];
|
|
12
|
+
key = map[key];
|
|
13
|
+
}
|
|
14
|
+
expr[key] = reduce(map, value, context, reverse);
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
return expr;
|
|
18
|
+
}, reverse = function(expr) {
|
|
19
|
+
if (that.isObject(expr)) {
|
|
20
|
+
that.iterate(expr, function(key, value) {
|
|
21
|
+
if (that.isObject(value)) {
|
|
22
|
+
expr[key] = reverse(value);
|
|
23
|
+
} else {
|
|
24
|
+
expr[value] = key;
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
return expr;
|
|
29
|
+
};
|
|
30
|
+
return [ function (state) {
|
|
31
|
+
that = this;
|
|
32
|
+
if(this.isEmpty(state.context.shorthand)) {
|
|
33
|
+
return state;
|
|
34
|
+
}
|
|
35
|
+
var data = state.context.data,
|
|
36
|
+
shorthand = state.context.shorthand;
|
|
37
|
+
if (!this.isEmpty(data)) {
|
|
38
|
+
if (!!shorthand.after || !!shorthand.before) {
|
|
39
|
+
shorthand = shorthand.before;
|
|
40
|
+
}
|
|
41
|
+
state.context.data = reduce(reverse(shorthand), data, state.context, false);
|
|
42
|
+
}
|
|
43
|
+
return state;
|
|
44
|
+
}, function (state) {
|
|
45
|
+
that = this;
|
|
46
|
+
if(this.isEmpty(state.context.shorthand)) {
|
|
47
|
+
return state;
|
|
48
|
+
}
|
|
49
|
+
var data = state.context.entry,
|
|
50
|
+
shorthand = state.context.shorthand;
|
|
51
|
+
if (!this.isEmpty(data)) {
|
|
52
|
+
if (!!shorthand.after || !!shorthand.before) {
|
|
53
|
+
shorthand = shorthand.after;
|
|
54
|
+
}
|
|
55
|
+
state.context.entry = reduce(shorthand, data, state.context);
|
|
56
|
+
}
|
|
57
|
+
return state;
|
|
58
|
+
} ];
|
|
59
|
+
}(self));
|