From 3ab7d356393bd03da3a7d6f75d3e2a277ddbae89 Mon Sep 17 00:00:00 2001 From: "kebler.net" Date: Fri, 23 Apr 2021 17:57:40 -0700 Subject: [PATCH] 0.2.0 move to native esm --- examples/example.js | 28 +++++++++++++--------------- package.json | 18 +++++++++--------- src/boolean.js | 4 ++-- test/boolean.test.js | 2 +- 4 files changed, 25 insertions(+), 27 deletions(-) diff --git a/examples/example.js b/examples/example.js index 97812bd..89b27be 100644 --- a/examples/example.js +++ b/examples/example.js @@ -1,17 +1,15 @@ -import Ready from '../src/ready' -import { EventEmitter } from 'events' +import toBooleanDefault from '../src/boolean.js' +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) diff --git a/package.json b/package.json index 658b886..c57e1dc 100644 --- a/package.json +++ b/package.json @@ -1,13 +1,14 @@ { "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", "main": "src/boolean.js", + "type": "module", "scripts": { - "example": "node -r esm examples/example", - "example:dev": "UCI_ENV=dev ./node_modules/.bin/nodemon -r esm examples/example", - "test": "./node_modules/.bin/mocha -r esm --timeout 30000 || exit 0", - "testd": "./node_modules/.bin/nodemon --exec './node_modules/.bin/mocha -r esm --timeout 30000' || exit 0" + "example": "node examples/example", + "example:dev": "UCI_ENV=dev ./node_modules/.bin/nodemon examples/example", + "test": "./node_modules/.bin/mocha --timeout 30000 || exit 0", + "testd": "./node_modules/.bin/nodemon --exec './node_modules/.bin/mocha --timeout 30000' || exit 0" }, "author": "David Kebler", "license": "MIT", @@ -24,9 +25,8 @@ "homepage": "https://github.com/uCOMmandIt/uci-utils#readme", "dependencies": {}, "devDependencies": { - "chai": "^4.2.0", - "esm": "^3.2.25", - "mocha": "^6.2.2", - "nodemon": "^1.19.4" + "chai": "^4.3.4", + "mocha": "^8.3.2", + "nodemon": "^2.0.7" } } diff --git a/src/boolean.js b/src/boolean.js index 7184585..d621a6a 100644 --- a/src/boolean.js +++ b/src/boolean.js @@ -1,5 +1,5 @@ -let rTrue=['t','true','y','yes','on','positive','up','enabled','affirmative','yea','sure','online','set','closed'] -let rFalse=['f','false','n','no','off','negative','down','disabled','nope','offline','unset','open'] +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','negatory','down','disabled','nope','offline','unset','open'] function createBoolean (opts={}) { return (value => { diff --git a/test/boolean.test.js b/test/boolean.test.js index 6b19616..d67842a 100644 --- a/test/boolean.test.js +++ b/test/boolean.test.js @@ -1,5 +1,5 @@ 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 () { it('should return false for undefined', function () {