-
Notifications
You must be signed in to change notification settings - Fork 16
/
eson.node.txt
46 lines (38 loc) · 3.72 KB
/
eson.node.txt
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
ESON
ALTERNATIVES ==> #See serialization formats summary
ESON #Extended JSON (Node module 0.5.0)
#Transcompiler for JSON: allow easier syntax that is transcompiled to real JSON.
#Usually for conf files.
#Not maintained anymore
ESONOBJ #new ESON
ESONOBJ.parse(JSON_STR) #
ESONOBJ.read(JSON_FILE) #Parse JSON. Cam omit ".json"
ESONOBJ.use #Adding JSON parsing filters functions ESONMIDWR()
(ESNMIDWR(KEY,STR,ESON)->STR2)#Some are available as
ESONOBJ.clone() #Returns ESONOBJ2
ESON.bools #ESONMIDWR: "yes|on|enabled" -> true, "no|off|disabled" -> false
ESON.ms #ESONMIDWR that takes human-readable time like "5s" or "5 days" and return NUM (ms)
ESON.dimensions #ESONMIDWR that "NUMxNUM2" -> { width NUM, width NUM2 }
ESON.replace(STR, STR2) #ESONMIDWR that STR -> STR2. Good idea to use delimiters to distinguish STR, e.g. "{...}"
ESON.include #ESONMIDWR that:
# - changes "include GPATH" to content of GPATH + ".json"
# - GPATH must:
# - be pointing a JSON file with ".json" extension
# - can be JSON raw type, e.g. STR or NUM
# - have ".json" extension stripped
# - relative path
# - GPATH can be several JSON_FILE using globbing:
# - if "include GPATH" -> merge them
# - if "include { GPATH }" -> { FILENAME: OBJ ... }
# - if "include [ GPATH ]" -> OBJ_ARR
ESON.glob #ESONMIDWR that "glob GPATH" -> "GPATH_ARR" (GPATH can use globbing, using GLOB() with default
#parameters, i.e. globstar, no dotfiles)
ESON.env([STR2]) #ESONMIDWR that, if ENVVAR KEY=STR3 and JSON has [STR2]KEY: STR, replace STR -> STR3
#ENVVAR should be uppercase with _, and KEY lowercase with spaces
#STR2 is "" by def., and should be uppercase ending with _
ESON.args([STR_ARR]) #Same for command line arguments (can be replaced by STR_ARR), e.g. --KEY STR3
#Should use dashes name in arguments, and spaces in KEY
#ARG_VAR should be same case with -, and KEY with spaces
#Can also use --[no-]KEY alone, which defaults to true|false