cavalion-js 1.0.67 โ 1.0.70
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/.js +0 -0
- package/.md +102 -0
- package/CHANGELOG.md +16 -0
- package/README.md +11 -1
- package/package.json +1 -1
- package/src/console/node/Array.js +5 -1
- package/src/js/JsObject.js +6 -6
- package/src/js/_js.js +43 -14
- package/src/js/nameOf.js +1 -1
- package/src/unrequire.js +3 -0
- package/src/util/Event.js +2 -1
- package/src/util/HotkeyManager.js +1 -0
package/.js
ADDED
|
File without changes
|
package/.md
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
* [CHANGELOG.md]() - [README.md]() - [package.json]() - [.js]()
|
|
2
|
+
|
|
3
|
+
# cavalion-js
|
|
4
|
+
|
|
5
|
+
# `0725`
|
|
6
|
+
|
|
7
|
+
Enhancing `js.groupBy` to accept multiple keys for grouping.
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
# `0429`
|
|
11
|
+
|
|
12
|
+
I want to be able to activate these source files with [an overlay]([!prototypes/Hover]{}) of Markdown. Or... no, I want to overlay the source I guess. ๐๐คจ๐ค
|
|
13
|
+
|
|
14
|
+
* [defineClass](src/js/:.js)
|
|
15
|
+
* [JsObject](src/js/:.js)
|
|
16
|
+
* [Method](src/js/:.js)
|
|
17
|
+
* [Class](src/js/:.js)
|
|
18
|
+
* [extensions](src/js/:.js)
|
|
19
|
+
* [mixIn](src/js/:.js)
|
|
20
|
+
* [nameOf](src/js/:.js)
|
|
21
|
+
* [Method](src/js/:.js)
|
|
22
|
+
* [Type](src/js/:.js)
|
|
23
|
+
|
|
24
|
+
Still, it would be nice to just
|
|
25
|
+
|
|
26
|
+
* Press (**โงโ.**) and overlay _the current context_ (whatever that might be anyways, probably a JavaScript module, rapportage-script) with _whatever_, starting with a _context-local_-[.md]()-file, sprouting in to whatever, but _mas-que-nada_ a starting point in order to...
|
|
27
|
+
* ...overlay notes, bookmarks, links, scripts, photos, ...
|
|
28
|
+
|
|
29
|
+
# `0424`
|
|
30
|
+
|
|
31
|
+
* `js.args(arr)` - concats and filters `arr` for non-undefined values
|
|
32
|
+
|
|
33
|
+
>> var v = (a, b, c, d) => control.vars.apply(control, js.args(a, b, c, d));
|
|
34
|
+
|
|
35
|
+
# cavalion-js
|
|
36
|
+
|
|
37
|
+
* [src](:/)
|
|
38
|
+
* [console](src/:/)
|
|
39
|
+
* [data](src/:/) - [design](src/:/)
|
|
40
|
+
* [entities](src/:/) - [entities.js](src/) - [features](src/:/)
|
|
41
|
+
* [js](src/:/) / [\_js.js](src/js/:) - [extensions.js](src/js/:) - _[global.js](src/js/:)_? - _[define.js](src/js/:)?_
|
|
42
|
+
- [defineClass.js](src/js/:) - [referenceClass.js](src/js/:)
|
|
43
|
+
- [js.js](src/:)
|
|
44
|
+
- [on.js](src/:)
|
|
45
|
+
- [nameOf.js](src/js/:)
|
|
46
|
+
- [mixIn.js](src/js/:) - [mixInRecursive.js](src/js/:)
|
|
47
|
+
- [minify.js](src/js/:) - [beautify.js](src/js/:) - [serialize.js](src/js/:)
|
|
48
|
+
- [util](src/:/) / [net](src/util/:/) / [HttpStatusCode.js](src/util/net/:) - [Url.js](src/util/net/:)
|
|
49
|
+
- [Ajax.js](src/util/:) - [Command.js](src/util/:)
|
|
50
|
+
- [Browser.js](src/util/:) - [CssSelectorParser.js](src/util/:)
|
|
51
|
+
- [DocumentHook.js](src/util/:) - [Event.js](src/util/:) - [Fullscreen.js](src/util/:)
|
|
52
|
+
- [HotkeyManager.js](src/util/:) - [HtmlElement.js](src/util/:)
|
|
53
|
+
- [Hash.js](src/util/:)
|
|
54
|
+
- [Keyboard.js](src/util/:)
|
|
55
|
+
- [Rest.js](src/util/:)
|
|
56
|
+
- [Stylesheet.js](src/util/:)
|
|
57
|
+
- [Xml.js](src/util/:)
|
|
58
|
+
- [json.js](src/:) - [locale.js](src/:) - [text.js](src/:)
|
|
59
|
+
- [script.js](src/:) - [relscript.js](src/:)
|
|
60
|
+
- [stylesheet.js](src/:)
|
|
61
|
+
- [persistence](src/:/) - [persistence2](src/:/)
|
|
62
|
+
- [test](src/:/) - [yell.js](src/:) - [unrequire.js](src/:)
|
|
63
|
+
|
|
64
|
+
#
|
|
65
|
+
|
|
66
|
+
- []()
|
|
67
|
+
- [ArrayFactory.js](src/js/:)
|
|
68
|
+
- [Class.js](src/js/:)
|
|
69
|
+
- [Deferred.js](src/js/:)
|
|
70
|
+
- [Enum.js](src/js/:)
|
|
71
|
+
- [Interface.js](src/js/:)
|
|
72
|
+
- [JsObject.js](src/js/:)
|
|
73
|
+
- [Method.js](src/js/:)
|
|
74
|
+
- [Object.js](src/js/:)
|
|
75
|
+
- [Packer.js](src/js/:)
|
|
76
|
+
- [Property.js](src/js/:)
|
|
77
|
+
- [Scaffold.js](src/js/:)
|
|
78
|
+
- [Type.js](src/js/:)
|
|
79
|
+
|
|
80
|
+
# js.nameOf for Array in console
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
# sort
|
|
84
|
+
|
|
85
|
+
> var by = (prop) => (i1, i2) => i1 < i2 ? -1 : i1 > i2 ? 1 : 0;
|
|
86
|
+
[].sort(by("date")); // dat zou moeten werken op 'echte' Date objecten ;-)
|
|
87
|
+
|
|
88
|
+
# filter
|
|
89
|
+
|
|
90
|
+
> var unique = (o, i, a) => a.indexOf(o) === i;
|
|
91
|
+
|
|
92
|
+
> var XXX = {
|
|
93
|
+
eq_: (prop, value) => (obj) => obj[prop] == value,
|
|
94
|
+
eq: (prop, value) => (obj) => obj[prop] === value,
|
|
95
|
+
neq: (prop, value) => (obj) => obj[prop] !== value,
|
|
96
|
+
gt: (prop, value) => (obj) => obj[prop] > value,
|
|
97
|
+
gte: (prop, value) => (obj) => obj[prop] >= value,
|
|
98
|
+
lt: (prop, value) => (obj) => obj[prop] < value,
|
|
99
|
+
lte: (prop, value) => (obj) => obj[prop] <= value,
|
|
100
|
+
contains: (prop, value) => (obj) => obj[prop].includes(value),
|
|
101
|
+
|
|
102
|
+
> var var_equals = (path, value) => (comp) => comp.vars(path) === value;
|
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
### 2022/07/28 - 1.0.70
|
|
2
|
+
|
|
3
|
+
* 2bb8d17 - updates/commits code that has been shipped for months now
|
|
4
|
+
* dc8fb8d - enhances js.groupBy for grouping on multiple attributes
|
|
5
|
+
* caa9abc - adds hint parameter to js.nameOf
|
|
6
|
+
* 004cc0f - clogs the latest changes
|
|
7
|
+
|
|
8
|
+
### 2022/03/28 - 1.0.69
|
|
9
|
+
|
|
10
|
+
* e3ce126 - Clogging
|
|
11
|
+
* 0d7badc - js/JsObject: Still refactoring [all !==> references (!)]
|
|
12
|
+
|
|
13
|
+
### 2022/03/28 - 1.0.68
|
|
14
|
+
|
|
15
|
+
* Updating
|
|
16
|
+
|
|
1
17
|
### 2022/01/02 - 1.0.67
|
|
2
18
|
|
|
3
19
|
* Introducing `js.nameOf.methods.set(name, impl)` - it allows for overriding/extending a certain method iteratively
|
package/README.md
CHANGED
package/package.json
CHANGED
|
@@ -19,7 +19,11 @@ define(["require", "js/defineClass", "../Node"], function(require, Array, Node)
|
|
|
19
19
|
*/
|
|
20
20
|
initializeValue: function(node) {
|
|
21
21
|
var arr = this.getArray();
|
|
22
|
-
|
|
22
|
+
if(arr.name instanceof Function) {
|
|
23
|
+
node.innerHTML = /*js.nameOf(arr)*/arr.name(arr) || js.sf("Array[%d]", arr.length);
|
|
24
|
+
} else {
|
|
25
|
+
node.innerHTML = /*js.nameOf(arr)*/arr.name || js.sf("Array[%d]", arr.length);
|
|
26
|
+
}
|
|
23
27
|
},
|
|
24
28
|
|
|
25
29
|
/**
|
package/src/js/JsObject.js
CHANGED
|
@@ -6,9 +6,9 @@ define(function(require) {
|
|
|
6
6
|
|
|
7
7
|
/** Keeps track of the next hashCode */
|
|
8
8
|
var hashCode = 0;
|
|
9
|
-
var
|
|
9
|
+
var references = [];
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
references.push = function() {
|
|
12
12
|
hashCode += arguments.length;
|
|
13
13
|
return Array.prototype.push.apply(this, arguments);
|
|
14
14
|
};
|
|
@@ -40,7 +40,7 @@ define(function(require) {
|
|
|
40
40
|
if(k !== "@hashCode") {
|
|
41
41
|
delete this[k];
|
|
42
42
|
} else {// if(this.hasOwnProperty("@hashCode")) {
|
|
43
|
-
delete
|
|
43
|
+
delete references[this['@hashCode']];
|
|
44
44
|
this['@hashCode'] = -this['@hashCode'];
|
|
45
45
|
}
|
|
46
46
|
}
|
|
@@ -53,7 +53,7 @@ define(function(require) {
|
|
|
53
53
|
}
|
|
54
54
|
this['@hashCode'] = hashCode++;
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
references[this['@hashCode']] = this;
|
|
57
57
|
|
|
58
58
|
return this['@hashCode'];
|
|
59
59
|
}
|
|
@@ -87,8 +87,8 @@ define(function(require) {
|
|
|
87
87
|
|
|
88
88
|
statics: {
|
|
89
89
|
|
|
90
|
-
$:
|
|
91
|
-
all:
|
|
90
|
+
$: references,
|
|
91
|
+
all: references
|
|
92
92
|
|
|
93
93
|
}
|
|
94
94
|
}));
|
package/src/js/_js.js
CHANGED
|
@@ -2,20 +2,23 @@ define(function(require) {
|
|
|
2
2
|
|
|
3
3
|
require("./extensions");
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var Method = require("./Method");
|
|
13
|
-
// var js;
|
|
5
|
+
const global = require("./global");
|
|
6
|
+
const minify = require("./minify");
|
|
7
|
+
const mixIn = require("./mixIn");
|
|
8
|
+
const beautify = require("./beautify");
|
|
9
|
+
const nameOf = require("./nameOf");
|
|
10
|
+
const serialize = require("./serialize");
|
|
11
|
+
const defineClass = require("./defineClass");
|
|
14
12
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
var js_ctx_key = "[[js.ctx]]";
|
|
13
|
+
const Method = require("./Method");
|
|
14
|
+
const JsObject = require("./JsObject");
|
|
18
15
|
|
|
16
|
+
const js_ctx_key = "[[js.ctx]]";
|
|
17
|
+
const groupBy = (arr, key) => arr.reduce((a, o) =>
|
|
18
|
+
((a[js.get(key, o)] || (a[js.get(key, o)] = []))
|
|
19
|
+
.push(o), a), {});
|
|
20
|
+
|
|
21
|
+
/*var js;*/
|
|
19
22
|
return (js = {
|
|
20
23
|
|
|
21
24
|
// handy-dandy
|
|
@@ -38,9 +41,35 @@ define(function(require) {
|
|
|
38
41
|
nameOf: nameOf,
|
|
39
42
|
defineClass: defineClass,
|
|
40
43
|
mixIn: mixIn,
|
|
41
|
-
groupBy: (arr, key) => {
|
|
42
|
-
|
|
44
|
+
// groupBy: (arr, key) => {
|
|
45
|
+
// return arr.reduce((a, o) => ((a[js.get(key, o)] || (a[js.get(key, o)] = [])).push(o), a), {});
|
|
46
|
+
// },
|
|
47
|
+
groupBy: (arr, keys, mth) => {
|
|
48
|
+
/*- groupBy: receives an array of objects and returns an object
|
|
49
|
+
which keys hold reference to the resulting groups.
|
|
50
|
+
|
|
51
|
+
arr: array to be grouped by keys
|
|
52
|
+
keys: array of strings, or comma-delimited string indicating the keys to group by
|
|
53
|
+
mth: optional, callback receiving and returning each group
|
|
54
|
+
*/
|
|
55
|
+
|
|
56
|
+
if(!(keys instanceof Array)) {
|
|
57
|
+
keys = keys.split(",");
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
var obj = groupBy(arr, keys.shift());
|
|
61
|
+
|
|
62
|
+
for(var k in obj) {
|
|
63
|
+
if(keys.length) {
|
|
64
|
+
obj[k] = js.groupBy(obj[k], [].concat(keys), mth);
|
|
65
|
+
} else if(mth) {
|
|
66
|
+
obj[k] = mth(obj[k]);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return obj;
|
|
43
71
|
},
|
|
72
|
+
|
|
44
73
|
ctx: function(obj, defaults) {
|
|
45
74
|
return obj.hasOwnProperty(js_ctx_key) ? obj[js_ctx_key] : obj[js_ctx_key] = (obj[js_ctx_key] || defaults || {});
|
|
46
75
|
},
|
package/src/js/nameOf.js
CHANGED
package/src/unrequire.js
CHANGED
package/src/util/Event.js
CHANGED
|
@@ -51,6 +51,7 @@ define(function(require) {
|
|
|
51
51
|
KEY_NUM_LOCK: 144,
|
|
52
52
|
KEY_SCROLL_LOCK: 145
|
|
53
53
|
},
|
|
54
|
+
window_Event: window.Event,
|
|
54
55
|
|
|
55
56
|
callListener: function(listener, curTarget) {
|
|
56
57
|
/**
|
|
@@ -170,7 +171,7 @@ define(function(require) {
|
|
|
170
171
|
modifiers.indexOf("metactrl") !== -1), modifiers);
|
|
171
172
|
},
|
|
172
173
|
modifiersMatch: function(evt, modifiers) {
|
|
173
|
-
if(!(evt instanceof
|
|
174
|
+
if(!(evt instanceof this.window_Event)) {
|
|
174
175
|
console.warn("This particular usage has been deprecated");
|
|
175
176
|
return this.modifiersMatchDeprecated(evt, modifiers);
|
|
176
177
|
}
|