1- "use strict" ;
1+ const toString = Object . prototype . toString ;
2+ const hasOwnProperty = Object . prototype . hasOwnProperty ;
3+ const coerce = ( x ) => x ;
24
3- var toString = Object . prototype . toString ;
4- var hasOwnProperty = Object . prototype . hasOwnProperty ;
5-
6- exports . _parse = function ( left , right , s ) {
5+ export const _parse = ( left , right , s ) => {
76 try {
87 return right ( JSON . parse ( s ) ) ;
98 }
@@ -12,57 +11,36 @@ exports._parse = function (left, right, s) {
1211 }
1312} ;
1413
15- exports . print = function ( j ) {
16- return JSON . stringify ( j ) ;
17- } ;
14+ export const print = ( j ) => JSON . stringify ( j ) ;
1815
19- exports . printIndented = function ( j ) {
20- return JSON . stringify ( j , null , 2 ) ;
21- } ;
16+ export const printIndented = ( j ) => JSON . stringify ( j , null , 2 ) ;
2217
23- exports . _case = function ( isNull , isBool , isNum , isStr , isArr , isObj , j ) {
18+ export const _case = ( isNull , isBool , isNum , isStr , isArr , isObj , j ) => {
2419 if ( j == null ) return isNull ( null ) ;
25- var ty = typeof j ;
20+ const ty = typeof j ;
2621 if ( ty === "boolean" ) return isBool ( j ) ;
2722 if ( ty === "number" ) return isNum ( j ) ;
2823 if ( ty === "string" ) return isStr ( j ) ;
2924 if ( toString . call ( j ) === "[object Array]" ) return isArr ( j ) ;
3025 return isObj ( j ) ;
3126} ;
3227
33- exports . _null = null ;
28+ export const _null = null ;
3429
35- var coerce = function ( x ) {
36- return x ;
37- } ;
30+ export const fromBoolean = coerce ;
3831
39- exports . fromBoolean = coerce ;
32+ export const fromNumberWithDefault = ( fallback ) => ( n ) => isNaN ( n ) || ! isFinite ( n ) ? fallback : n ;
4033
41- exports . fromNumberWithDefault = function ( x ) {
42- return function ( y ) {
43- if ( isNaN ( y ) || ! isFinite ( y ) ) return x ;
44- return y ;
45- } ;
46- } ;
34+ export const fromInt = coerce ;
4735
48- exports . fromInt = coerce ;
36+ export const fromString = coerce ;
4937
50- exports . fromString = coerce ;
38+ export const fromArray = coerce ;
5139
52- exports . fromArray = coerce ;
40+ export const fromObject = coerce ;
5341
54- exports . fromObject = coerce ;
42+ export const _entries = ( tuple , obj ) =>
43+ Object . entries ( obj ) . map ( ( [ k , v ] ) => tuple ( k ) ( v ) ) ;
5544
56- exports . _entries = function ( tuple , obj ) {
57- var result = [ ] ;
58- for ( var k in obj ) {
59- if ( hasOwnProperty . call ( obj , k ) ) {
60- result [ k ] = tuple ( k , obj [ k ] ) ;
61- }
62- }
63- return result ;
64- } ;
65-
66- exports . _lookup = function ( nothing , just , key , obj ) {
67- return hasOwnProperty . call ( obj , key ) ? just ( obj [ key ] ) : nothing ;
68- } ;
45+ export const _lookup = ( nothing , just , key , obj ) =>
46+ hasOwnProperty . call ( obj , key ) ? just ( obj [ key ] ) : nothing ;
0 commit comments