0.2.0 move to native esm
parent
41e2df91eb
commit
3ab7d35639
|
@ -1,17 +1,15 @@
|
||||||
import Ready from '../src/ready'
|
import toBooleanDefault from '../src/boolean.js'
|
||||||
import { EventEmitter } from 'events'
|
import { toBoolean, createBoolean, rTrue, rFalse } from '../src/boolean.js'
|
||||||
|
|
||||||
let emitter = new EventEmitter()
|
const boolean=toBoolean()
|
||||||
|
console.log(rTrue)
|
||||||
|
console.log(rFalse)
|
||||||
|
console.log('nope',toBoolean('nope'))
|
||||||
|
console.log('yes',toBoolean('yes'))
|
||||||
|
console.log('undefined',toBoolean(undefined))
|
||||||
|
console.log('null',toBoolean('null'))
|
||||||
|
console.log('0',toBoolean(0))
|
||||||
|
console.log(toBoolean('yes'))
|
||||||
|
console.log('-1',toBoolean(-1))
|
||||||
|
console.log('1', toBoolean(1))
|
||||||
|
|
||||||
let process = new Ready({emitter: emitter, condition: (ev=> {return ev===true}) })
|
|
||||||
|
|
||||||
process.addObserver('one')
|
|
||||||
process.addObserver('two')
|
|
||||||
process.addObserver('three')
|
|
||||||
|
|
||||||
process.subscribe()
|
|
||||||
|
|
||||||
emitter.emit('one',true)
|
|
||||||
emitter.emit('two',true)
|
|
||||||
emitter.emit('three',true)
|
|
||||||
emitter.emit('one',false)
|
|
||||||
|
|
18
package.json
18
package.json
|
@ -1,13 +1,14 @@
|
||||||
{
|
{
|
||||||
"name": "@uci-utils/to-boolean",
|
"name": "@uci-utils/to-boolean",
|
||||||
"version": "0.1.5",
|
"version": "0.2.0",
|
||||||
"description": "function to return a boolean value from sets of default values",
|
"description": "function to return a boolean value from sets of default values",
|
||||||
"main": "src/boolean.js",
|
"main": "src/boolean.js",
|
||||||
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"example": "node -r esm examples/example",
|
"example": "node examples/example",
|
||||||
"example:dev": "UCI_ENV=dev ./node_modules/.bin/nodemon -r esm examples/example",
|
"example:dev": "UCI_ENV=dev ./node_modules/.bin/nodemon examples/example",
|
||||||
"test": "./node_modules/.bin/mocha -r esm --timeout 30000 || exit 0",
|
"test": "./node_modules/.bin/mocha --timeout 30000 || exit 0",
|
||||||
"testd": "./node_modules/.bin/nodemon --exec './node_modules/.bin/mocha -r esm --timeout 30000' || exit 0"
|
"testd": "./node_modules/.bin/nodemon --exec './node_modules/.bin/mocha --timeout 30000' || exit 0"
|
||||||
},
|
},
|
||||||
"author": "David Kebler",
|
"author": "David Kebler",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
@ -24,9 +25,8 @@
|
||||||
"homepage": "https://github.com/uCOMmandIt/uci-utils#readme",
|
"homepage": "https://github.com/uCOMmandIt/uci-utils#readme",
|
||||||
"dependencies": {},
|
"dependencies": {},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"chai": "^4.2.0",
|
"chai": "^4.3.4",
|
||||||
"esm": "^3.2.25",
|
"mocha": "^8.3.2",
|
||||||
"mocha": "^6.2.2",
|
"nodemon": "^2.0.7"
|
||||||
"nodemon": "^1.19.4"
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
let rTrue=['t','true','y','yes','on','positive','up','enabled','affirmative','yea','sure','online','set','closed']
|
let rTrue=['t','true','y','yes','on','affirmative','positive','up','enabled','affirmative','yea','yep','sure','online','set','closed']
|
||||||
let rFalse=['f','false','n','no','off','negative','down','disabled','nope','offline','unset','open']
|
let rFalse=['f','false','n','no','off','negative','negatory','down','disabled','nope','offline','unset','open']
|
||||||
|
|
||||||
function createBoolean (opts={}) {
|
function createBoolean (opts={}) {
|
||||||
return (value => {
|
return (value => {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import { expect } from 'chai'
|
import { expect } from 'chai'
|
||||||
import {toBoolean, createBoolean, rTrue,rFalse }from '../src/boolean'
|
import {toBoolean, createBoolean, rTrue,rFalse } from '../src/boolean.js'
|
||||||
|
|
||||||
describe('No options default function check - ', function () {
|
describe('No options default function check - ', function () {
|
||||||
it('should return false for undefined', function () {
|
it('should return false for undefined', function () {
|
||||||
|
|
Loading…
Reference in New Issue