Skip to content

Commit

Permalink
feat(list,records): add support for list, rec, rec:kv types
Browse files Browse the repository at this point in the history
build(deps): update dependencies, prep for esm
  • Loading branch information
kollhof committed Oct 6, 2020
1 parent dfe18be commit 9b1e78d
Show file tree
Hide file tree
Showing 82 changed files with 738 additions and 602 deletions.
5 changes: 3 additions & 2 deletions jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ module.exports = {
moduleFileExtensions: ['js', 'fnk'],
transform: {
'^.+\\.js$': 'babel-jest',
'^.+\\.fnk$': ['@fink/jest/transform']
'^.+\\.fnk$': ['@fink/jest/transform.js']
},
transformIgnorePatterns: ['<rootDir>/node_modules/', '<rootDir>/build/'],

snapshotResolver: '@fink/jest/snapshot-resolver',
resolver: '@fink/jest/cjs/module-resolver.js',
snapshotResolver: '@fink/jest/snapshot-resolver.js',

modulePathIgnorePatterns: ['<rootDir>/build/'],

Expand Down
821 changes: 450 additions & 371 deletions package-lock.json

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"clean": "rimraf ./build",
"build": "run build:*",
"build:dir": "mkdir -p ./build/pkg/",
"build:fnk": "fnk --src ./src --out-dir ./build/pkg --ignore '**/*.test.fnk'",
"build:fnk": "fnk --module-type cjs --src ./src --out-dir ./build/pkg --ignore '**/*.test.fnk'",
"build:files": "cp package.json ./README.md ./LICENSE ./build/pkg/",
"test": "run jest",
"jest": "jest --verbose --runInBand --no-cache ",
Expand All @@ -36,22 +36,22 @@
}
},
"devDependencies": {
"@fink/cli": "^6.2.1",
"@fink/jest": "^5.4.0",
"@fink/cli": "^7.0.0",
"@fink/jest": "^6.0.0",
"@fink/larix": "^12.3.0",
"@fink/loxia": "^12.4.0",
"@fink/loxia": "^13.0.1",
"commitizen": "^4.1.2",
"cz-conventional-changelog": "^3.1.0",
"jest-cli": "^26.1.0",
"jest-cli": "^26.5.2",
"npx-run": "^2.1.2",
"semantic-release": "^17.1.2"
},
"dependencies": {
"@babel/core": "^7.10.5",
"@babel/traverse": "^7.10.5",
"@babel/types": "^7.10.5",
"@fink/js-interop": "^1.1.1",
"@fink/std-lib": "^4.0.1",
"@fink/snippet": "^1.0.0"
"@fink/js-interop": "^2.0.0",
"@fink/std-lib": "^5.0.0",
"@fink/snippet": "^2.0.0"
}
}
10 changes: 5 additions & 5 deletions src/index.fnk
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{default: traverse} = import '@babel/traverse'
{transformFromAstSync} = import '@babel/core'
{is_empty} = import '@fink/std-lib/iter'
{is_empty} = import '@fink/std-lib/iter.fnk'

{transform_ast} = import './lang'
{transform_ast} = import './lang/index.fnk'

{transform_do_expr} = import './js/do-expression'
{transform_async} = import './js/async'
{module_transforms} = import './js/module'
{transform_do_expr} = import './js/do-expression.fnk'
{transform_async} = import './js/async.fnk'
{module_transforms} = import './js/module.fnk'



Expand Down
9 changes: 5 additions & 4 deletions src/index.test.fnk
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{describe, it, expect, to_equal, to_match_snapshot} = import '@fink/jest'
{slice} = import '@fink/std-lib/str'
{describe, it, expect, to_equal, to_match_snapshot} = import '@fink/jest/test.fnk'
{slice} = import '@fink/std-lib/str.fnk'

{generate} = import './index.fnk'
{fink2js} = import './testing/index.fnk'

{generate} = import '.'
{fink2js} = import './testing'


describe 'module types', fn:
Expand Down
2 changes: 1 addition & 1 deletion src/js/async.fnk
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{isArrowFunctionExpression, isFunctionExpression, isForOfStatement} = import '@babel/types'
{set_props} = import '@fink/js-interop/reflect'
{set_props} = import '@fink/js-interop/reflect.fnk'


[no_result] = []
Expand Down
16 changes: 11 additions & 5 deletions src/js/do-expression.fnk
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,23 @@
isVariableDeclarator, isArrowFunctionExpression, isExpressionStatement
isReturnStatement, arrowFunctionExpression, callExpression
} = import '@babel/types'
{set_props} = import '@fink/js-interop/reflect'
{undefined} = import '@fink/js-interop/nullish'
{is_empty} = import '@fink/std-lib/iter'
{wrap_with_comment_loc} = import '../lang/comments'
{set_props} = import '@fink/js-interop/reflect.fnk'
{undefined} = import '@fink/js-interop/nullish.fnk'
{is_empty} = import '@fink/std-lib/iter.fnk'
{wrap_with_comment_loc} = import '../lang/comments/index.fnk'

{lets, assign, undef} = import './types.fnk'

{lets, assign, undef} = import './types'

get_body = fn path: path.get 'body'



# TODO: suport _ or nothing instead of having to use item
consume_all = fold item: undefined



simple = fn body, sl=false:
match body:
isBlockStatement ?:
Expand All @@ -41,6 +43,7 @@ simple = fn body, sl=false:
body.node



last_expressions = fn path:
match path:
isDoExpression ?:
Expand Down Expand Up @@ -90,6 +93,7 @@ last_expressions = fn path:
...last_expressions body



replace_with_return = fn path:
pipe last_expressions path:
map expr:
Expand All @@ -115,6 +119,7 @@ replace_with_return = fn path:
consume_all



replace_with_assign = fn target, path:
id = path.parentPath.scope.generateUidIdentifier 'do_result'
#TODO: don't mutate
Expand All @@ -135,6 +140,7 @@ replace_with_assign = fn target, path:
consume_all



transform_do_expr = fn path:
{parentPath: parent} = path

Expand Down
11 changes: 7 additions & 4 deletions src/js/identifier.fnk
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{char_code, slice} = import '@fink/std-lib/str'
{rx , matches} = import '@fink/std-lib/regex'
{char_code, slice} = import '@fink/std-lib/str.fnk'
{rx , matches} = import '@fink/std-lib/regex.fnk'
{length} = import '@fink/std-lib/iter.fnk'
{base_n} = import '@fink/std-lib/num.fnk'

{length} = import '@fink/std-lib/iter'
{base_n} = import '@fink/std-lib/num'


check_ident = rx'
Expand All @@ -15,11 +15,13 @@ check_ident = rx'
[_$\p{L}][_$\p{L}\p{N}]*$'



var_prefix = 'ˆ'

str_36 = base_n ?, 36



replace_chars = fn name, idx=0:
prefixed_name = '${var_prefix}${name}'

Expand All @@ -36,6 +38,7 @@ replace_chars = fn name, idx=0:
replace_chars new_name, idx + length char_replacement



escape_ident = fn name:
match name:
matches ?, check_ident:
Expand Down
4 changes: 2 additions & 2 deletions src/js/types.fnk
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
logicalExpression, binaryExpression, unaryExpression
doExpression, assignmentExpression, isIdentifier
} = import'@babel/types'
{is_empty} = import '@fink/std-lib/iter'
{is_empty} = import '@fink/std-lib/iter.fnk'


{escape_ident} = import'./identifier'
{escape_ident} = import'./identifier.fnk'


wrap = fn larix_node, js_node:
Expand Down
2 changes: 1 addition & 1 deletion src/lang/arithmitic/index.fnk
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{binaryExpression, unaryExpression} = import '@babel/types'
{add, any} = import '../context'
{add, any} = import '../context.fnk'


transform_op = dict:
Expand Down
4 changes: 2 additions & 2 deletions src/lang/arithmitic/index.test.fnk
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{fink2js} = import '../../testing'
{describe, it, expect, to_match_snapshot} = import '@fink/jest'
{fink2js} = import '../../testing/index.fnk'
{describe, it, expect, to_match_snapshot} = import '@fink/jest/test.fnk'


describe 'binary', fn:
Expand Down
16 changes: 8 additions & 8 deletions src/lang/assignment/index.fnk
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
memberExpression, identifier, expressionStatement, arrayPattern, restElement
numericLiteral
} = import '@babel/types'
{length, is_empty} = import '@fink/std-lib/iter'
{wrap_with_comment_loc} = import '../comments'
{length, is_empty} = import '@fink/std-lib/iter.fnk'
{wrap_with_comment_loc} = import '../comments/index.fnk'


{transform_left} = import '../../js/left'
{add, any} = import '../context'
{transform_value} = import '../partial'
{transform_left} = import '../../js/left.fnk'
{add, any} = import '../context.fnk'
{transform_value} = import '../partial/index.fnk'


# TODO: std-lib
Expand All @@ -20,7 +20,7 @@ find_index = fn iterable, func:

has_spread_not_last = fn {left}:
match left:
{type: 'array', exprs: 1 < length ?}:
{type: ? in ['array', 'list'], exprs: 1 < length ?}:
idx = find_index left.exprs, fn expr:
match expr:
{type: 'spread'}: true
Expand Down Expand Up @@ -50,10 +50,10 @@ transform_spread_left = fn {left}, {transform}:
exprs = match before:
is_empty ?:
# TODO missing loc
[middle, {type: 'array', exprs: end}]
[middle, {type: 'list', exprs: end}]
else:
# TODO missing loc
[{type: 'array', exprs: before}, middle, {type: 'array', exprs: end}]
[{type: 'list', exprs: before}, middle, {type: 'list', exprs: end}]

transform_left transform {...left, exprs}

Expand Down
4 changes: 2 additions & 2 deletions src/lang/assignment/index.test.fnk
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{fink2js} = import '../../testing'
{describe, it, expect, to_match_snapshot} = import '@fink/jest'
{fink2js} = import '../../testing/index.fnk'
{describe, it, expect, to_match_snapshot} = import '@fink/jest/test.fnk'


describe 'assignment', fn:
Expand Down
2 changes: 1 addition & 1 deletion src/lang/async/index.fnk
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{awaitExpression} = import '@babel/types'
{add, any} = import '../context'
{add, any} = import '../context.fnk'


transform_await = fn node, {transform}:
Expand Down
4 changes: 2 additions & 2 deletions src/lang/async/index.test.fnk
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{fink2js} = import '../../testing'
{describe, it, expect, to_match_snapshot} = import '@fink/jest'
{fink2js} = import '../../testing/index.fnk'
{describe, it, expect, to_match_snapshot} = import '@fink/jest/test.fnk'


describe 'await', fn:
Expand Down
6 changes: 3 additions & 3 deletions src/lang/block/index.fnk
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
doExpression, blockStatement, isAssignmentExpression, expressionStatement
variableDeclaration, variableDeclarator
} = import '@babel/types'
{length} = import '@fink/std-lib/iter'
{length} = import '@fink/std-lib/iter.fnk'

{add, any} = import '../context'
{wrap_with_comment_loc} = import '../comments'
{add, any} = import '../context.fnk'
{wrap_with_comment_loc} = import '../comments/index.fnk'


block_statement = fn expr, {transform}:
Expand Down
2 changes: 1 addition & 1 deletion src/lang/call/call.fnk
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{callExpression, identifier} = import '@babel/types'
{is_empty, length} = import '@fink/std-lib/iter'
{is_empty, length} = import '@fink/std-lib/iter.fnk'


transform_args = fn args, {transform}:
Expand Down
4 changes: 2 additions & 2 deletions src/lang/call/call.test.fnk
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{fink2js} = import '../../testing'
{describe, it, expect, to_match_snapshot} = import '@fink/jest'
{fink2js} = import '../../testing/index.fnk'
{describe, it, expect, to_match_snapshot} = import '@fink/jest/test.fnk'


describe 'call', fn:
Expand Down
6 changes: 3 additions & 3 deletions src/lang/call/index.fnk
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{add, any} = import '../context'
{transform_call} = import './call'
{transform_pipe} = import './pipe'
{add, any} = import '../context.fnk'
{transform_call} = import './call.fnk'
{transform_pipe} = import './pipe.fnk'


add_call = fn ctx:
Expand Down
7 changes: 4 additions & 3 deletions src/lang/call/pipe.fnk
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{callExpression} = import'@babel/types'
{is_empty} = import'@fink/std-lib/iter'

{assign, lets, expr_block, undef} = import '../../js/types'
{transform_value} = import '../partial'
{wrap_with_comment_loc} = import '../comments'
{assign, lets, expr_block, undef} = import '../../js/types.fnk'
{transform_value} = import '../partial/index.fnk'
{wrap_with_comment_loc} = import '../comments/index.fnk'



transform_pipe = fn node, ctx:
Expand Down
4 changes: 2 additions & 2 deletions src/lang/call/pipe.test.fnk
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{fink2js} = import '../../testing'
{describe, it, expect, to_match_snapshot} = import '@fink/jest'
{fink2js} = import '../../testing/index.fnk'
{describe, it, expect, to_match_snapshot} = import '@fink/jest/test.fnk'


describe 'pipe', fn:
Expand Down
4 changes: 2 additions & 2 deletions src/lang/comments/index.test.fnk
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{fink2js} = import '../../testing'
{describe, it, expect, to_match_snapshot} = import '@fink/jest'
{fink2js} = import '../../testing/index.fnk'
{describe, it, expect, to_match_snapshot} = import '@fink/jest/test.fnk'


describe 'comment', fn:
Expand Down
5 changes: 4 additions & 1 deletion src/lang/comparison/index.fnk
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
{binaryExpression, logicalExpression} = import '@babel/types'

{add, any} = import '../context'
{add, any} = import '../context.fnk'



transform_op = dict:
'==': '==='
'!=': '!=='



transform_comp = fn {op, left, right}, {transform}:
{(op): operator=op} = transform_op

Expand All @@ -26,6 +28,7 @@ transform_comp = fn {op, left, right}, {transform}:
binaryExpression operator, bin_left, bin_right



add_comparison = fn ctx:
pipe ctx:
add 'comp', any, transform_comp
Expand Down
4 changes: 2 additions & 2 deletions src/lang/comparison/index.test.fnk
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{fink2js} = import '../../testing'
{describe, it, expect, to_match_snapshot} = import '@fink/jest'
{fink2js} = import '../../testing/index.fnk'
{describe, it, expect, to_match_snapshot} = import '@fink/jest/test.fnk'


describe 'comparison', fn:
Expand Down
5 changes: 3 additions & 2 deletions src/lang/conditionals/index.fnk
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{add, any} = import '../context'
{transform_match} = import './match'
{add, any} = import '../context.fnk'
{transform_match} = import './match.fnk'



add_conditionals = fn ctx:
Expand Down
Loading

0 comments on commit 9b1e78d

Please sign in to comment.