fez-lisp 1.5.183 → 1.5.185

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/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "fez-lisp",
3
3
  "description": "Lisp interpreted & compiled to JavaScript",
4
4
  "author": "AT290690",
5
- "version": "1.5.183",
5
+ "version": "1.5.185",
6
6
  "type": "module",
7
7
  "main": "index.js",
8
8
  "keywords": [
package/src/macros.js CHANGED
@@ -31,7 +31,8 @@ export const SUGGAR = {
31
31
  CREATE_MAP: 'new:map',
32
32
  POWER: '**',
33
33
  INTEGER_DEVISION: '//',
34
- CONDITION: 'cond'
34
+ CONDITION: 'cond',
35
+ PROMISES: '*DATA*'
35
36
  }
36
37
  export const deSuggarAst = (ast, scope) => {
37
38
  if (scope === undefined) scope = ast
package/src/parser.js CHANGED
@@ -42,6 +42,20 @@ export const LISP = {
42
42
  .join(' ')})`
43
43
  else return array
44
44
  },
45
+ json: (item) => {
46
+ if (item === null) return 0
47
+ else if (typeof item === 'boolean') return item
48
+ else if (typeof item === 'string') return `"${item}"`
49
+ // return item.split('').map((x) => x.charCodeAt())
50
+ else if (typeof item === 'object')
51
+ if (Array.isArray(item))
52
+ return item.length ? `[${item.map(LISP.json).join(' ')}]` : '[]'
53
+ else
54
+ return `({ ${Object.entries(item)
55
+ .map(([key, value]) => `"${key}" ${LISP.json(value)}`)
56
+ .join(' ')} })`
57
+ else return item
58
+ },
45
59
  source: (ast) => {
46
60
  const dfs = (exp) => {
47
61
  let out = ''