functionalscript 0.0.515 → 0.0.517

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/README.md CHANGED
@@ -13,7 +13,9 @@ FunctionalScript is a purely functional programming language and a strict subset
13
13
 
14
14
  Create a new FunctionalScript repository on GitHub [here](https://github.com/functionalscript/template/generate).
15
15
 
16
- Learn more about [FunctionalScript](https://medium.com/@sergeyshandar/purely-functional-programming-in-javascript-91114b1b2dff).
16
+ Learn more about
17
+ - [Purely Functional Programming in JavaScript](https://medium.com/@sergeyshandar/purely-functional-programming-in-javascript-91114b1b2dff),
18
+ - [FunctionalScript](https://medium.com/@sergeyshandar/functionalscript-5cf817345376).
17
19
 
18
20
  ## Design Principles
19
21
 
@@ -1,12 +1,11 @@
1
1
  const list = require('../types/list/module.f.cjs')
2
- const { next, flat, reduce, map, empty } = list
2
+ const { flat, map, empty } = list
3
3
  const { concat } = require('../types/string/module.f.cjs')
4
4
  const object = require('../types/object/module.f.cjs')
5
- const { at } = object
6
- const operator = require('../types/function/operator/module.f.cjs')
7
5
  const { compose, fn } = require('../types/function/module.f.cjs')
8
6
  const { entries } = Object
9
7
  const { serialize: bigintSerialize } = require('../types/bigint/module.f.cjs')
8
+ const { objectWrap, arrayWrap, stringSerialize, numberSerialize, nullSerialize, boolSerialize } = require('../json/serializer/module.f.cjs')
10
9
 
11
10
  /**
12
11
  * @typedef {{
@@ -18,42 +17,7 @@ const { serialize: bigintSerialize } = require('../types/bigint/module.f.cjs')
18
17
 
19
18
  /** @typedef {Object|boolean|string|number|null|Array|bigint} Unknown */
20
19
 
21
- const jsonStringify = JSON.stringify
22
-
23
- /** @type {(_: string) => list.List<string>} */
24
- const stringSerialize = input => [jsonStringify(input)]
25
-
26
- /** @type {(_: number) => list.List<string>} */
27
- const numberSerialize = input => [jsonStringify(input)]
28
-
29
- const nullSerialize = ['null']
30
-
31
- const trueSerialize = ['true']
32
-
33
- const falseSerialize = ['false']
34
-
35
- /** @type {(_: boolean) => list.List<string>} */
36
- const boolSerialize = value => value ? trueSerialize : falseSerialize
37
-
38
20
  const colon = [':']
39
- const comma = [',']
40
-
41
- /** @type {operator.Reduce<list.List<string>>} */
42
- const joinOp = b => prior => flat([prior, comma, b])
43
-
44
- /** @type {(input: list.List<list.List<string>>) => list.List<string>} */
45
- const join = reduce(joinOp)(empty)
46
-
47
- /** @type {(open: string) => (close: string) => (input: list.List<list.List<string>>) => list.List<string>} */
48
- const wrap = open => close => {
49
- const seqOpen = [open]
50
- const seqClose = [close]
51
- return input => flat([seqOpen, join(input), seqClose])
52
- }
53
-
54
- const objectWrap = wrap('{')('}')
55
-
56
- const arrayWrap = wrap('[')(']')
57
21
 
58
22
  /** @typedef {object.Entry<Unknown>} Entry*/
59
23
 
package/json/module.f.cjs CHANGED
@@ -1,11 +1,11 @@
1
1
  const list = require('../types/list/module.f.cjs')
2
- const { next, flat, reduce, map, empty } = list
2
+ const { next, flat, map, empty } = list
3
3
  const { concat } = require('../types/string/module.f.cjs')
4
4
  const object = require('../types/object/module.f.cjs')
5
5
  const { at } = object
6
- const operator = require('../types/function/operator/module.f.cjs')
7
6
  const { compose, fn } = require('../types/function/module.f.cjs')
8
7
  const { entries } = Object
8
+ const { objectWrap, arrayWrap, stringSerialize, numberSerialize, nullSerialize, boolSerialize } = require('./serializer/module.f.cjs')
9
9
 
10
10
  /**
11
11
  * @typedef {{
@@ -30,42 +30,7 @@ const setProperty = value => {
30
30
  return f
31
31
  }
32
32
 
33
- const jsonStringify = JSON.stringify
34
-
35
- /** @type {(_: string) => list.List<string>} */
36
- const stringSerialize = input => [jsonStringify(input)]
37
-
38
- /** @type {(_: number) => list.List<string>} */
39
- const numberSerialize = input => [jsonStringify(input)]
40
-
41
- const nullSerialize = ['null']
42
-
43
- const trueSerialize = ['true']
44
-
45
- const falseSerialize = ['false']
46
-
47
- /** @type {(_: boolean) => list.List<string>} */
48
- const boolSerialize = value => value ? trueSerialize : falseSerialize
49
-
50
33
  const colon = [':']
51
- const comma = [',']
52
-
53
- /** @type {operator.Reduce<list.List<string>>} */
54
- const joinOp = b => prior => flat([prior, comma, b])
55
-
56
- /** @type {(input: list.List<list.List<string>>) => list.List<string>} */
57
- const join = reduce(joinOp)(empty)
58
-
59
- /** @type {(open: string) => (close: string) => (input: list.List<list.List<string>>) => list.List<string>} */
60
- const wrap = open => close => {
61
- const seqOpen = [open]
62
- const seqClose = [close]
63
- return input => flat([seqOpen, join(input), seqClose])
64
- }
65
-
66
- const objectWrap = wrap('{')('}')
67
-
68
- const arrayWrap = wrap('[')(']')
69
34
 
70
35
  /** @typedef {object.Entry<Unknown>} Entry*/
71
36
 
@@ -0,0 +1,101 @@
1
+ const list = require('../../types/list/module.f.cjs')
2
+ const { flat, reduce, empty } = list
3
+ const object = require('../../types/object/module.f.cjs')
4
+ const operator = require('../../types/function/operator/module.f.cjs')
5
+
6
+ /**
7
+ * @template T
8
+ * @typedef {{
9
+ * readonly [k in string]: Unknown<T>
10
+ * }} Obj<T>
11
+ */
12
+
13
+ /**
14
+ * @template T
15
+ * @typedef {readonly Unknown<T>[]} Arr<T>
16
+ */
17
+
18
+ /**
19
+ * @typedef {|
20
+ * boolean |
21
+ * string |
22
+ * number |
23
+ * null
24
+ * } Primitive
25
+ */
26
+
27
+ /**
28
+ * @template T
29
+ * @typedef {|
30
+ * Arr<T>|
31
+ * Obj<T>|
32
+ * null|
33
+ * T
34
+ * } Unknown<T>
35
+ */
36
+
37
+ const jsonStringify = JSON.stringify
38
+
39
+ /** @type {(_: string) => list.List<string>} */
40
+ const stringSerialize = input => [jsonStringify(input)]
41
+
42
+ /** @type {(_: number) => list.List<string>} */
43
+ const numberSerialize = input => [jsonStringify(input)]
44
+
45
+ const nullSerialize = ['null']
46
+
47
+ const trueSerialize = ['true']
48
+
49
+ const falseSerialize = ['false']
50
+
51
+ /** @type {(_: boolean) => list.List<string>} */
52
+ const boolSerialize = value => value ? trueSerialize : falseSerialize
53
+
54
+ const comma = [',']
55
+
56
+ /** @type {operator.Reduce<list.List<string>>} */
57
+ const joinOp = b => prior => flat([prior, comma, b])
58
+
59
+ /** @type {(input: list.List<list.List<string>>) => list.List<string>} */
60
+ const join = reduce(joinOp)(empty)
61
+
62
+ /** @type {(open: string) => (close: string) => (input: list.List<list.List<string>>) => list.List<string>} */
63
+ const wrap = open => close => {
64
+ const seqOpen = [open]
65
+ const seqClose = [close]
66
+ return input => flat([seqOpen, join(input), seqClose])
67
+ }
68
+
69
+ const objectWrap = wrap('{')('}')
70
+
71
+ const arrayWrap = wrap('[')(']')
72
+
73
+ /**
74
+ * @template T
75
+ * @typedef {object.Entry<Unknown<T>>} Entry<T>
76
+ */
77
+
78
+ /**
79
+ * @template T
80
+ * @typedef {(list.List<Entry<T>>)} Entries<T>
81
+ */
82
+
83
+ /**
84
+ * @template T
85
+ * @typedef {(entries: Entries<T>) => Entries<T>} MapEntries<T>
86
+ */
87
+
88
+ module.exports = {
89
+ /** @readonly */
90
+ objectWrap,
91
+ /** @readonly */
92
+ arrayWrap,
93
+ /** @readonly */
94
+ stringSerialize,
95
+ /** @readonly */
96
+ numberSerialize,
97
+ /** @readonly */
98
+ nullSerialize,
99
+ /** @readonly */
100
+ boolSerialize,
101
+ }
@@ -0,0 +1,4 @@
1
+ const serializer = require('./module.f.cjs')
2
+
3
+ module.exports = {
4
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "functionalscript",
3
- "version": "0.0.515",
3
+ "version": "0.0.517",
4
4
  "description": "FunctionalScript is a functional subset of JavaScript",
5
5
  "main": "module.f.cjs",
6
6
  "scripts": {