Skip to content

Commit

Permalink
Merge pull request #3 from fink-lang/features
Browse files Browse the repository at this point in the history
Features
  • Loading branch information
kollhof authored Jul 18, 2020
2 parents 5095ad8 + ece54d5 commit f832eb6
Show file tree
Hide file tree
Showing 7 changed files with 103 additions and 43 deletions.
60 changes: 49 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,19 +21,18 @@
"build": "run build:*",
"build:dir": "mkdir -p ./build/pkg/",
"build:fnk": "fnk --src ./src --out-dir build/pkg --ignore './src/**/*.test.fnk'",
"build:js": "cp ./src/this.js ./src/nullish.js ./build/pkg/",
"build:js": "cp ./src/globals.js ./src/this.js ./src/reflect.js ./src/nullish.js ./build/pkg/",
"build:files": "cp ./package.json ./README.md ./LICENSE ./build/pkg/",
"test": "run jest",
"jest": "jest --verbose --runInBand --no-cache ",
"cd": "run clean test build release",
"release": "semantic-release"
},
"devDependencies": {
"@fink/cli": "^6.0.0",
"@fink/cli": "^6.1.0",
"@fink/jest": "^5.0.0",
"@fink/larix": "^12.0.0",
"@fink/loxia": "^12.0.0",
"@fink/std-lib": "^2.4.0",
"@fink/loxia": "^12.0.2",
"commitizen": "^4.0.5",
"cz-conventional-changelog": "^3.1.0",
"jest-cli": "^26.1.0",
Expand Down
1 change: 1 addition & 0 deletions src/globals.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = globalThis;
5 changes: 2 additions & 3 deletions src/nullish.test.fnk
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
{describe, it, expect, to_equal} = import '@fink/jest'

{obj_to_json} = import '@fink/std-lib/json'

{null, undefined} = import './nullish'
{JSON} = import './globals'


describe 'null, undefined', fn:
it 'exports JS null', fn:
expect
obj_to_json null
JSON.stringify null
to_equal 'null'


Expand Down
23 changes: 0 additions & 23 deletions src/reflect.fnk

This file was deleted.

26 changes: 26 additions & 0 deletions src/reflect.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@

exports.ˆnew = (cls, ...args)=> Reflect.construct(cls, args);

exports.apply = Reflect.apply;

exports.has = Reflect.has;
exports.get = Reflect.get;
exports.set = Reflect.set;
exports.set_props = Object.assign;

exports.delete_property = Reflect.deleteProperty;
exports.define_property = Reflect.defineProperty;

exports.own_keys = Reflect.ownKeys;

exports.get_own_property_descriptor = Reflect.getOwnPropertyDescriptor;

exports.get_prototype_of = Reflect.getPrototypeOf;
exports.set_prototype_of = Reflect.setPrototypeOf;

exports.is_extensible = Reflect.isExtensible;
exports.prevent_extensions = Reflect.preventExtensions;

exports.get_type = (obj)=> typeof obj;

exports.is_instance = (obj, cls)=> obj instanceof cls;
24 changes: 22 additions & 2 deletions src/reflect.test.fnk
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
new, has, get, set, set_props,
delete_property, define_property, get_own_property_descriptor,
get_prototype_of, set_prototype_of,
is_extensible, prevent_extensions
is_extensible, prevent_extensions,
get_type, is_instance
} = import './reflect'

{String, Array} = import './globals'


describe 'reflect', fn:
Expand Down Expand Up @@ -105,4 +107,22 @@ describe 'new', fn:

expect
enc.constructor
to_equal String
to_equal String



describe 'typeof', fn:
it 'gets type of obj', fn:
expect
get_type 'foobar'
to_equal 'string'



describe 'instanceof', fn:
it 'check instanceof', fn:
expect
is_instance [], Array
to_equal true


0 comments on commit f832eb6

Please sign in to comment.