-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathalienese.js
383 lines (297 loc) · 10.1 KB
/
alienese.js
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
/*
MIT License
Copyright (c) 2025 Estre Soliette (SoliEstre)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
*/
// Alienise.js - Estre javscript Alienese patch //
//
// A collection of aliases for shortening and simplifying JavaScript code.
// This patch aims to create smaller (quicker) and more concise (lighter) JavaScript code.
// It makes the code more implicit and serves as an alternative to obfuscation.
//
// v0.3 / release 2025.04.25
//
// * Must be loaded modernism.js before this script.
//
// Author: Estre Soliette
// Established: 2025.01.05 / Extracted: 2025.03.15
// primitive types alias constant
const U = UNDEFINED;
const N = NULL;
const T = TRUE;
const F = FALSE;
const u = undefined;
const n = null;
const t = true;
const f = false;
// end point assigner constant
const eoo = u;
const eoa = u;
// prototype of primitive types alias constant
const FNC = FUNCTION;
const BLE = BOOLEAN;
const STR = STRING;
const SYM = SYMBOL;
const NUM = NUMBER;
const BIG = BIGINT;
const OBJ = OBJECT;
const fun = Function;
const ble = Boolean;
const str = String;
const sym = Symbol;
const num = Number;
const big = BigInt;
const obj = Object;
// class names of primitive types constant
const FN = _FUNCTION;
const BL = _BOOLEAN;
const ST = _STRING;
const SY = _SYMBOL;
const NO = _NUMBER;
const BI = _BIG_INT;
const OJ = _OBJECT;
const fn = Function;
const bl = Boolean;
const sg = String;
const sl = Symbol;
const no = Number;
const bi = BigInt;
const oj = Object;
// frequent object types alias constant
const DT = _DATE;
const RA = _ARRAY;
const SA = _SET;
const MA = _MAP;
const dt = Date;
const ra = Array;
const sa = Set;
const ma = Map;
// frequent assign types alias constant
const def = DEFAULT;
const fin = FINALLY;
// frequent object types empty object issuer alias constant
const x = {
get a() { return new Array(); },
get d() { return new Date(); },
get t() { return new Set(); },
get p() { return new Map(); },
};
// bypass constant
const ifx = executeIf;
const itx = executeWhen;
const ifr = ifReturn;
const roen = ifReturnOrEmptyNumber;
const roes = ifReturnOrEmptyString;
const roea = ifReturnOrEmptyArray;
const roeo = ifReturnOrEmptyObject;
const val = valet;
// common process shortcut constant
const f02b = forZeroToBefore;
const f02r = forZeroToReach;
const f20 = forToZeroFrom;
const f21 = forToPrimeFrom;
const ff = forForward;
const fb = forBackward;
const fi = forin;
const fiv = forinner;
const fo = forof;
const fkv = forkv;
const w = whileIn;
const dw = doWhileIn;
// meaning comparator constant
const to = typeOf;
const tm = typeMatch;
const tu = typeUndefined;
const tf = typeFunction;
const tb = typeBoolean;
const ts = typeString;
const ty = typeSymbol;
const tn = typeNumber;
const tg = typeBigint;
const tj = typeObject;
const im = instanceMatch;
const io = isObject;
const ia = isArray;
const ioa = isArray;
const ios = isString;
const ion = isNumber;
const iot = isSet;
const iop = isMap;
const xv = exact;
const nxv = notExact;
const xm = exactMatches;
const nx = notExactMatches;
const ev = equals;
const nev = notEquals;
const sm = same;
const df = diffrent;
const gtv = getherThan;
const ltv = lessThan;
const ngt = notGetherThan;
const nlt = notLessThan;
const gev = getherOrEquals;
const lev = lessOrEquels;
const nge = notGetherAndEquals;
const nle = notLessAndEquals;
const fc = isFalseCase;
const nfc = isTrueCase;
const xu = isUndefined;
const xn = isNull;
const xt = isExactTrue;
const xf = isExactFalse;
const nxu = isNotUndefined;
const nxn = isNotNull;
const nxt = isNotTrue;
const nxf = isNotFalse;
const en = isNully;
const et = isTruely;
const ef = isFalsely;
const ee = isEmpty;
const nn = isNotNully;
const nt = isNotTruely;
const nf = isNotFalsely;
const ne = isNotEmpty;
const noe = isNullOrEmpty;
const nne = isNotNullAndEmpty;
// quick execute by conditions constant
const inoe = ifNullOrEmpty;
const inne = ifNotNullAndEmpty;
// do and return inline double takes
const dr = doAndReturn;
const drx = doAndReturnByExecute;
// object method shortcut constant
const ok = keysOf;
const ov = valuesOf;
const oe = entriesOf;
const oc = countOf;
const occ = checkCount;
// match case constant
const mc = matchCase;
const ec = equalCase;
const xc = exactCase;
const tc = typeCase;
const cc = classCase;
const kc = kindCase;
/** variable data copy */
const cp = copy;
const mk = mock;
const mm = mimic;
const tw = twin;
const cn = clone;
const pc = patch;
const ow = overwrite;
const tk = takeover;
const aq = acquire;
const ih = inherit;
const rv = revert;
/** run handle */
const pq = postQueue;
const pd = postDelayed;
const pp = postPromise;
const pb = postBonded;
const paq = postAsyncQueue;
const pfq = postFrameQueue;
// Object function shortcut constants
const dsp = defineStaticProperty;
const dp = defineProperty;
const dpx = definePropertyPlex;
const dspgs = defineStaticGetterAndSetter;
const dpgs = defineGetterAndSetter;
const dpgsx = defineGetterAndSetterPlex;
// additional static function for classes
defineStaticGetterAndSetter(dt, "n", function () { return new Date(...arguments); });
defineStaticGetterAndSetter(dt, "t", function () { return this.now(); });
// additional global prototype functions
definePropertyPlex("mc", function () { return matchCase(this.it, ...arguments); });
definePropertyPlex("ec", function () { return equalCase(this.it, ...arguments); });
definePropertyPlex("xc", function () { return exactCase(this.it, ...arguments); });
definePropertyPlex("tc", function () { return typeCase(this.it, ...arguments); });
definePropertyPlex("cc", function () { return classCase(this.it, ...arguments); });
definePropertyPlex("kc", function () { return kindCase(this.it, ...arguments); });
definePropertyPlex("ee", function (process = it => it, ornot = it => it, numberEmptyMatch = 0) { return isEmpty(this.it, numberEmptyMatch) ? process(this.it) : ornot(this.it); });
definePropertyPlex("ne", function (process = it => it, ornot = it => it, numberEmptyMatch = 0) { return isNotEmpty(this.it, numberEmptyMatch) ? process(this.it) : ornot(this.it); });
definePropertyPlex("dr", function (does = (it, args) => {}, returns, args = []) { return doAndReturn(does, returns, [this.it, ...args]); });
definePropertyPlex("drx", function (does = (it, args) => {}, forReturns, args = []) { return doAndReturnByExecute(does, forReturns, [this.it, ...args]); });
defineGetterAndSetter(Object, "ok", function () { return keysOf(this.it); });
defineGetterAndSetter(Object, "ov", function () { return valuesOf(this.it); });
defineGetterAndSetter(Object, "oe", function () { return entriesOf(this.it); });
defineGetterAndSetter(Object, "oc", function () { return countOf(this.it); });
defineGetterAndSetter(Object, "occ", function () { return checkCount(this.it, (k, v) => true); });
defineProperty(Object, "fk", function (work = key => { return false; }) { return forof(this.it.ways, work); });
defineProperty(Object, "fv", function (work = value => { return false; }) { return forof(this.it.looks, work); });
defineProperty(Object, "fe", function (work = (key, value) => { return false; }) { return forkv(this.it.entire, work); });
defineProperty(Object, "fkv", function (work = (key, value) => { return false; }) { return forkv(this.it.entire, work); });
defineProperty(Object, "cp", function (dataOnly = true, primitiveOnly = false, recusive = true) { return copy(this, dataOnly, primitiveOnly, recusive); });
defineProperty(Object, "pc", function (from, dataOnly = true, primitiveOnly = false, recusive = true, append = false) { return patch(this.it, from, dataOnly, primitiveOnly, recusive, append); });
defineProperty(Object, "rv", function (from, dataOnly = true, primitiveOnly = false, recusive = true, exceptNew = false) { return revert(this.it, from, dataOnly, primitiveOnly, recusive, exceptNew); });
definePropertyPlex("ifeq", function (that, process = it => it, ornot = it => {}) { return this.let(it => executeIf(it == that, process, [it], ornot)); });
definePropertyPlex("ifneq", function (that, process = it => it, ornot = it => {}) { return this.let(it => executeIf(it != that, process, [it], ornot)); });
// Regex builder alias
const rx = (regex, flags) => new RegExp(regex, flags);
const reg = rx;
const ri = regex => new RegExp(regex, "i");
const rg = regex => new RegExp(regex, "g");
const rm = regex => new RegExp(regex, "m");
const rig = regex => new RegExp(regex, "ig");
const rim = regex => new RegExp(regex, "im");
const rgm = regex => new RegExp(regex, "gm");
const rigm = regex => new RegExp(regex, "igm");
// common extra characters constants
const lt = "<";
const gt = ">";
const ab = lt + gt;
const cb = gt + lt;
const ti = "~";
const ep = "!";
const em = ep;
const at = "@";
const ds = "$";
const ms = "&";
const ps = "%";
const cf = "^";
const ak = "*";
const mp = ak;
const ad = "+";
const add = ad + ad;
const hp = "-";
const sr = hp;
const srr = sr + sr;
const us = "_";
const eq = "=";
const vl = "|";
const bs = "\\";
const ss = "/";
const dv = ss;
const qm = "?";
const nl = ep + eq;
const le = lt + eq;
const ge = gt + eq;
const fa = ad + eq;
const fs = sr + eq;
const fm = mp + eq;
const fd = dv + eq;
const sq = "'";
const dq = '"';
const gv = '`';
const cl = ":";
const sc = ";";
const cm = ",";
const es = "";
const l = cm;
const s = " ";
const i = "#";
const d = ".";