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 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
@@ -1,3 +1,13 @@
1
1
  # cavalion-js
2
2
 
3
- Cavalion common JavaScript library.
3
+ ## TL;DR:
4
+
5
+ Cavalion common JavaScript library.
6
+
7
+ ## src/js.js
8
+
9
+ * Entry point for RequireJS
10
+
11
+ require.config({ paths: { js: "`${npm("cavalion-js")}`/src/js"}})
12
+
13
+ require("js");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cavalion-js",
3
- "version": "1.0.67",
3
+ "version": "1.0.70",
4
4
  "description": "Cavalion common JavaScript library",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -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
- node.innerHTML = arr.name || js.sf("Array[%d]", arr.length);
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
  /**
@@ -6,9 +6,9 @@ define(function(require) {
6
6
 
7
7
  /** Keeps track of the next hashCode */
8
8
  var hashCode = 0;
9
- var all = [];
9
+ var references = [];
10
10
 
11
- all.push = function() {
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 all[this['@hashCode']];
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
- all[this['@hashCode']] = this;
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
- $: all,
91
- all: 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
- var global = require("./global");
6
- var minify = require("./minify");
7
- var mixIn = require("./mixIn");
8
- var beautify = require("./beautify");
9
- var nameOf = require("./nameOf");
10
- var serialize = require("./serialize");
11
- var defineClass = require("./defineClass");
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
- var JsObject = require("./JsObject");
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
- return arr.reduce((a, o) => ((a[js.get(key, o)] || (a[js.get(key, o)] = [])).push(o), a), {});
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
@@ -31,7 +31,7 @@ define(function() {
31
31
  return (methods[name] = impl);
32
32
  };
33
33
 
34
- function nameOf(obj, test) {
34
+ function nameOf(obj, hint, test) {
35
35
  if(obj === undefined || obj === null) return String(obj);
36
36
 
37
37
  for(var i = methods.before.length - 1, r; i >= 0; --i) {
package/src/unrequire.js CHANGED
@@ -1,4 +1,7 @@
1
1
  define(function() {
2
+
3
+ /*- https://stackoverflow.com/questions/11899967/require-js-remove-definition-to-force-reload */
4
+
2
5
  return function unrequire(require) {
3
6
 
4
7
  };
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 window.Event)) {
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
  }
@@ -25,6 +25,7 @@ define(function(require) {
25
25
  this._listeners = {};
26
26
  },
27
27
  register: function(hotkey, li) {
28
+ /* type, keyCode, callback, modifiers */
28
29
  if(typeof li === "object") {
29
30
  if(typeof hotkey === "string") {
30
31
  li.modifiers = hotkey.toLowerCase().split("+");