0.0.1 • Published 3 years ago

mol_strict v0.0.1

Weekly downloads
-
License
-
Repository
-
Last release
3 years ago

$mol_strict

Makes JS runtime more strict.

Without $mol_strict

class Foo extends Object {}
const foo = new Foo

`Hello, ${ foo }!`
// "Hello [object Object]!"

`In this month you have earned ${ foo / 1000 } thousand of dollars.`
// "In this month you have earned NaN thousand of dollars."

`Your "${ 'foo'[4] }" goal is finally achieved.`
// "Your "undefined" goal is finally achieved."

`There are still ${ foo.length - 1 } goals left and you will achieve success.`
// "There are still NaN goals left and you will achieve success."

With $mol_strict

class Foo extends Object {}
const foo = new Foo

`Hello, ${ foo }!`
// TypeError: Field "Symbol(Symbol.toPrimitive)" is not defined

`In this month you have earned ${ foo / 1000 } thousand of dollars.`
// TypeError: Field "Symbol(Symbol.toPrimitive)" is not defined

`Your "${ 'foo'[4] }" goal is finally achieved.`
// TypeError: Field "4" is not defined

`There are still ${ foo.length - 1 } goals left and you will achieve success.`
// TypeError: Field "length" is not defined

Usage from MAM

At any *.meta.tree:

include \/mol/strict

Usage from NPM

import "mol_strict"