diff --git a/package-lock.json b/package-lock.json index 87aacab..9257e7d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -420,14 +420,25 @@ "optional": true }, "@fink/cli": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/@fink/cli/-/cli-6.0.0.tgz", - "integrity": "sha512-U8fXwA07HEESma6C6TjMtVUI+xUQLo7Byt8a+JUNA/ozImpdFfe9Ibi4tTD1QSPatSKxpSxtoT0mSnnBKP31IQ==", + "version": "6.1.0", + "resolved": "https://registry.npmjs.org/@fink/cli/-/cli-6.1.0.tgz", + "integrity": "sha512-P6omfYUBkqkRdtjmweziemjfaZW9/wmH7LEOc4IM4WyLLbR7o/jH+W5+zsAzvN1yTMMQ7o6EP2wQ2RSAUKWZCQ==", "dev": true, "requires": { - "@fink/std-lib": "^2.0.0", + "@fink/std-lib": "^3.0.0", "minimatch": "^3.0.4", "yargs": "^15.3.1" + }, + "dependencies": { + "@fink/std-lib": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@fink/std-lib/-/std-lib-3.0.0.tgz", + "integrity": "sha512-EC2fCkRBeL3kTfpFgNSroYDrQgYrfdH2WkAsFMzuFwbvrTiAiOHZmBkgCcdhAG8bl79tnwjFY/F/K4BmoQimZA==", + "dev": true, + "requires": { + "@fink/js-interop": "^1.0.0" + } + } } }, "@fink/jest": { @@ -440,6 +451,12 @@ "@fink/std-lib": "^2.0.0" } }, + "@fink/js-interop": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/@fink/js-interop/-/js-interop-1.0.0.tgz", + "integrity": "sha512-erKeeOKVNVPXfIK9p0hWW/C2RgNZ/W0HjlCWhWbtx9TLxQKDBebbMhyYbK5oPm5QyIJ8JnAiiOu7EjEAqOKgNA==", + "dev": true + }, "@fink/larix": { "version": "12.0.0", "resolved": "https://registry.npmjs.org/@fink/larix/-/larix-12.0.0.tgz", @@ -451,14 +468,27 @@ } }, "@fink/loxia": { - "version": "12.0.0", - "resolved": "https://registry.npmjs.org/@fink/loxia/-/loxia-12.0.0.tgz", - "integrity": "sha512-R0AWoEkvzHvlULPzOA2qWzW53mVw5wjEwv9GmZrVncdZaT/EBT3YwZ3QZ4PafABdX1Yea8zo9ZRqGeFs2O4osQ==", + "version": "12.0.2", + "resolved": "https://registry.npmjs.org/@fink/loxia/-/loxia-12.0.2.tgz", + "integrity": "sha512-/fT+pws7uMVnfZAb8CMzVLVuyNa0u1X+Bf8ejr87+Sabsv+GlO/CCwcwBapuOmztBY66yFmtvTJAfxhfoDT6Xg==", "dev": true, "requires": { "@babel/core": "^7.10.4", "@babel/traverse": "^7.10.4", - "@babel/types": "^7.10.4" + "@babel/types": "^7.10.4", + "@fink/js-interop": "^1.0.0", + "@fink/std-lib": "^3.0.0" + }, + "dependencies": { + "@fink/std-lib": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/@fink/std-lib/-/std-lib-3.0.0.tgz", + "integrity": "sha512-EC2fCkRBeL3kTfpFgNSroYDrQgYrfdH2WkAsFMzuFwbvrTiAiOHZmBkgCcdhAG8bl79tnwjFY/F/K4BmoQimZA==", + "dev": true, + "requires": { + "@fink/js-interop": "^1.0.0" + } + } } }, "@fink/prattler": { @@ -2426,6 +2456,14 @@ "minimist": "1.2.5", "strip-bom": "4.0.0", "strip-json-comments": "3.0.1" + }, + "dependencies": { + "lodash": { + "version": "4.17.15", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", + "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==", + "dev": true + } } }, "compare-func": { @@ -6006,9 +6044,9 @@ } }, "lodash": { - "version": "4.17.15", - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", - "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==", + "version": "4.17.19", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.19.tgz", + "integrity": "sha512-JNvd8XER9GQX0v2qJgsaN/mzFCNA5BRe/j8JN9d+tWyGLSodKQHKFicdwNYzWwI3wjRnaKPsGj1XkBjx/F96DQ==", "dev": true }, "lodash.capitalize": { diff --git a/package.json b/package.json index 262da69..b44ba8a 100644 --- a/package.json +++ b/package.json @@ -21,7 +21,7 @@ "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 ", @@ -29,11 +29,10 @@ "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", diff --git a/src/globals.js b/src/globals.js new file mode 100644 index 0000000..6d41ca0 --- /dev/null +++ b/src/globals.js @@ -0,0 +1 @@ +module.exports = globalThis; \ No newline at end of file diff --git a/src/nullish.test.fnk b/src/nullish.test.fnk index 8b2e5e8..4f53f7a 100644 --- a/src/nullish.test.fnk +++ b/src/nullish.test.fnk @@ -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' diff --git a/src/reflect.fnk b/src/reflect.fnk deleted file mode 100644 index 11b902c..0000000 --- a/src/reflect.fnk +++ /dev/null @@ -1,23 +0,0 @@ - -new = fn cls, ...args: - Reflect.construct cls, args - -apply = Reflect.apply - -has = Reflect.has -get = Reflect.get -set = Reflect.set -set_props = Object.assign - -delete_property = Reflect.deleteProperty -define_property = Reflect.defineProperty - -own_keys = Reflect.ownKeys - -get_own_property_descriptor = Reflect.getOwnPropertyDescriptor - -get_prototype_of = Reflect.getPrototypeOf -set_prototype_of = Reflect.setPrototypeOf - -is_extensible = Reflect.isExtensible -prevent_extensions = Reflect.preventExtensions diff --git a/src/reflect.js b/src/reflect.js new file mode 100644 index 0000000..fe1e85f --- /dev/null +++ b/src/reflect.js @@ -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; diff --git a/src/reflect.test.fnk b/src/reflect.test.fnk index a8aad55..cb23f7a 100644 --- a/src/reflect.test.fnk +++ b/src/reflect.test.fnk @@ -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: @@ -105,4 +107,22 @@ describe 'new', fn: expect enc.constructor - to_equal String \ No newline at end of file + 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 + +