Skip to content

Commit

Permalink
[npm publish] - npm publish 2019.10.8
Browse files Browse the repository at this point in the history
- merge function local.valueOrEmptyXxx into local.coalesce
  • Loading branch information
kai.zhu committed Oct 9, 2019
1 parent cd15a69 commit f0eadff
Show file tree
Hide file tree
Showing 5 changed files with 108 additions and 121 deletions.
97 changes: 41 additions & 56 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ this zero-dependency package will provide browser-compatible versions of jslint

[![travis-ci.org build-status](https://api.travis-ci.org/kaizhu256/node-jslint-lite.svg)](https://travis-ci.org/kaizhu256/node-jslint-lite) [![coverage](https://kaizhu256.github.io/node-jslint-lite/build/coverage.badge.svg)](https://kaizhu256.github.io/node-jslint-lite/build/coverage.html/index.html)

[![NPM](https://nodei.co/npm/jslint-lite.png?downloads=true)](https://www.npmjs.com/package/jslint-lite)

[![build commit status](https://kaizhu256.github.io/node-jslint-lite/build/build.badge.svg)](https://travis-ci.org/kaizhu256/node-jslint-lite)

| git-branch : | [master](https://github.com/kaizhu256/node-jslint-lite/tree/master) | [beta](https://github.com/kaizhu256/node-jslint-lite/tree/beta) | [alpha](https://github.com/kaizhu256/node-jslint-lite/tree/alpha)|
Expand All @@ -22,6 +24,8 @@ this zero-dependency package will provide browser-compatible versions of jslint

[![npmPackageListing](https://kaizhu256.github.io/node-jslint-lite/build/screenshot.npmPackageListing.svg)](https://github.com/kaizhu256/node-jslint-lite)

![npmPackageDependencyTree](https://kaizhu256.github.io/node-jslint-lite/build/screenshot.npmPackageDependencyTree.svg)



# table of contents
Expand Down Expand Up @@ -57,8 +61,9 @@ this zero-dependency package will provide browser-compatible versions of jslint
- jslint - sort nested switch-statements
- none

#### changelog 2019.9.7
- npm publish 2019.9.7
#### changelog 2019.10.8
- npm publish 2019.10.8
- merge function local.valueOrEmptyXxx into local.coalesce
- jslint - update function jslintAndPrint's opt.lineOffset with opt.iiStart, opt.iiEnd
- streamline evt-handling in example.js
- merge polyfills into assets.example.begin.js
Expand Down Expand Up @@ -117,15 +122,14 @@ this script will run a web-demo of jslint-lite
instruction
1. save this script as example.js
2. run shell-command:
$ npm install kaizhu256/node-jslint-lite#alpha && \
$ npm install jslint-lite && \
PORT=8081 node example.js
3. open a browser to http://127.0.0.1:8081 and play with web-demo
4. edit this script to suit your needs
*/



/* istanbul instrument in package jslint */
// assets.utility2.header.js - start
/* istanbul ignore next */
/* jslint utility2:true */
Expand Down Expand Up @@ -188,6 +192,12 @@ instruction
*/
return this.map(...argList).flat();
};
String.prototype.trimEnd = (
String.prototype.trimEnd || String.prototype.trimRight
);
String.prototype.trimStart = (
String.prototype.trimStart || String.prototype.trimLeft
);
(function () {
try {
globalThis.TextDecoder = (
Expand Down Expand Up @@ -334,11 +344,27 @@ instruction
// if message is a string, then leave as is
? message
// else JSON.stringify message
: JSON.stringify(message, null, 4)
: JSON.stringify(message, undefined, 4)
)
);
throw err;
};
local.coalesce = function (...argList) {
/*
* this function will coalesce null, undefined, or "" in <argList>
*/
let arg;
let ii;
ii = 0;
while (ii < argList.length) {
arg = argList[ii];
if (arg !== null && arg !== undefined && arg !== "") {
break;
}
ii += 1;
}
return arg;
};
local.fsRmrfSync = function (dir) {
/*
* this function will sync "rm -rf" <dir>
Expand Down Expand Up @@ -395,6 +421,12 @@ instruction
*/
return fnc || local.nop;
};
local.identity = function (val) {
/*
* this function will return <val>
*/
return val;
};
local.nop = function () {
/*
* this function will do nothing
Expand All @@ -403,8 +435,7 @@ instruction
};
local.objectAssignDefault = function (target, source) {
/*
* this function will if items from <target> are
* null, undefined, or empty-string,
* this function will if items from <target> are null, undefined, or "",
* then overwrite them with items from <source>
*/
target = target || {};
Expand Down Expand Up @@ -439,30 +470,6 @@ instruction
&& Array.from(document.querySelectorAll(selectors))
) || [];
};
local.value = function (val) {
/*
* this function will return <val>
*/
return val;
};
local.valueOrEmptyList = function (val) {
/*
* this function will return <val> or []
*/
return val || [];
};
local.valueOrEmptyObject = function (val) {
/*
* this function will return <val> or {}
*/
return val || {};
};
local.valueOrEmptyString = function (val) {
/*
* this function will return <val> or ""
*/
return val || "";
};
// require builtin
if (!local.isBrowser) {
local.assert = require("assert");
Expand Down Expand Up @@ -500,7 +507,6 @@ instruction



/* istanbul ignore next */
/* jslint utility2:true */
(function (local) {
"use strict";
Expand Down Expand Up @@ -543,7 +549,7 @@ if (!local.isBrowser) {
return (
typeof arg === "string"
? arg
: JSON.stringify(arg, null, 4)
: JSON.stringify(arg, undefined, 4)
);
}).join(" ").replace((
/\u001b\[\d*m/g
Expand All @@ -554,7 +560,6 @@ if (!local.isBrowser) {
});
local.objectAssignDefault(local, globalThis.domOnEventDelegateDict);
globalThis.domOnEventDelegateDict = local;
local.onEventDomDb = local.db && local.db.onEventDomDb;
if ((
/\bmodeTest=1\b/
).test(location.search)) {
Expand All @@ -564,7 +569,6 @@ if ((



/* istanbul ignore next */
// run node js-env code - init-test
(function () {
if (local.isBrowser) {
Expand Down Expand Up @@ -607,19 +611,6 @@ local.assetsDict["/assets.index.template.html"] = '\
box-sizing: border-box;\n\
}\n\
/* csslint ignore:end */\n\
@keyframes uiAnimateShake {\n\
0%,\n\
50% {\n\
transform: translateX(10px);\n\
}\n\
100% {\n\
transform: translateX(0);\n\
}\n\
25%,\n\
75% {\n\
transform: translateX(-10px);\n\
}\n\
}\n\
@keyframes uiAnimateSpin {\n\
0% {\n\
transform: rotate(0deg);\n\
Expand Down Expand Up @@ -691,10 +682,6 @@ pre {\n\
overflow: auto;\n\
padding: 2px;\n\
}\n\
.uiAnimateShake {\n\
animation-duration: 500ms;\n\
animation-name: uiAnimateShake;\n\
}\n\
.uiAnimateSlide {\n\
overflow-y: hidden;\n\
transition: max-height ease-in 250ms, min-height ease-in 250ms, padding-bottom ease-in 250ms, padding-top ease-in 250ms;\n\
Expand All @@ -710,8 +697,6 @@ pre {\n\
</head>\n\
<body>\n\
<div class="uiAnimateSpin" style="animation: uiAnimateSpin 2s linear infinite; border: 5px solid #999; border-radius: 50%; border-top: 5px solid #7d7; display: none; height: 25px; vertical-align: middle; width: 25px;"></div>\n\
<a class="zeroPixel" download="db.persistence.json" href="" id="dbExportA1"></a>\n\
<input class="zeroPixel" data-onevent="onEventDomDb" data-onevent-db="dbImportInput" type="file">\n\
<script>\n\
/* jslint utility2:true */\n\
// init domOnEventWindowOnloadTimeElapsed\n\
Expand Down Expand Up @@ -1279,7 +1264,7 @@ local.http.createServer(function (req, res) {
"test": "./npm_scripts.sh",
"utility2": "./npm_scripts.sh"
},
"version": "2019.9.7"
"version": "2019.10.8"
}
```

Expand All @@ -1305,7 +1290,7 @@ shBuildCiAfter () {(set -e
)}

shBuildCiBefore () {(set -e
#!! shNpmTestPublished
shNpmTestPublished
shReadmeTest example.js
)}

Expand Down
67 changes: 34 additions & 33 deletions lib.jslint.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env node
/*
* lib.jslint.js (2019.9.7)
* lib.jslint.js (2019.10.8)
* https://github.com/kaizhu256/node-jslint-lite
* this zero-dependency package will provide browser-compatible versions of jslint (v2019.8.3) and csslint (v1.0.5), with a working web-demo
*
Expand Down Expand Up @@ -71,6 +71,12 @@
*/
return this.map(...argList).flat();
};
String.prototype.trimEnd = (
String.prototype.trimEnd || String.prototype.trimRight
);
String.prototype.trimStart = (
String.prototype.trimStart || String.prototype.trimLeft
);
(function () {
try {
globalThis.TextDecoder = (
Expand Down Expand Up @@ -217,11 +223,27 @@
// if message is a string, then leave as is
? message
// else JSON.stringify message
: JSON.stringify(message, null, 4)
: JSON.stringify(message, undefined, 4)
)
);
throw err;
};
local.coalesce = function (...argList) {
/*
* this function will coalesce null, undefined, or "" in <argList>
*/
let arg;
let ii;
ii = 0;
while (ii < argList.length) {
arg = argList[ii];
if (arg !== null && arg !== undefined && arg !== "") {
break;
}
ii += 1;
}
return arg;
};
local.fsRmrfSync = function (dir) {
/*
* this function will sync "rm -rf" <dir>
Expand Down Expand Up @@ -278,6 +300,12 @@
*/
return fnc || local.nop;
};
local.identity = function (val) {
/*
* this function will return <val>
*/
return val;
};
local.nop = function () {
/*
* this function will do nothing
Expand All @@ -286,8 +314,7 @@
};
local.objectAssignDefault = function (target, source) {
/*
* this function will if items from <target> are
* null, undefined, or empty-string,
* this function will if items from <target> are null, undefined, or "",
* then overwrite them with items from <source>
*/
target = target || {};
Expand Down Expand Up @@ -322,30 +349,6 @@
&& Array.from(document.querySelectorAll(selectors))
) || [];
};
local.value = function (val) {
/*
* this function will return <val>
*/
return val;
};
local.valueOrEmptyList = function (val) {
/*
* this function will return <val> or []
*/
return val || [];
};
local.valueOrEmptyObject = function (val) {
/*
* this function will return <val> or {}
*/
return val || {};
};
local.valueOrEmptyString = function (val) {
/*
* this function will return <val> or ""
*/
return val || "";
};
// require builtin
if (!local.isBrowser) {
local.assert = require("assert");
Expand Down Expand Up @@ -475,16 +478,14 @@ local.cliRun = function (opt) {
try {
commandList[ii] = opt.rgxComment.exec(text);
commandList[ii] = {
argList: local.valueOrEmptyString(
commandList[ii][1]
).trim(),
argList: local.coalesce(commandList[ii][1], "").trim(),
command: [
key
],
description: commandList[ii][2]
};
} catch (ignore) {
local.assertOrThrow(null, new Error(
local.assertOrThrow(undefined, new Error(
"cliRun - cannot parse comment in COMMAND "
+ key
+ ":\nnew RegExp("
Expand Down Expand Up @@ -542,7 +543,7 @@ local.cliRun = function (opt) {
* will start interactive-mode
*/
globalThis.local = local;
local.value(local.replStart || require("repl").start)({
local.identity(local.replStart || require("repl").start)({
useGlobal: true
});
};
Expand Down
1 change: 0 additions & 1 deletion npm_scripts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ shMain () {(set -e
if [ "$npm_package_nameLib" = utility2 ]
then
export PORT=$(./lib.utility2.sh shServerPortRandom)
export PORT_REPL=$(./lib.utility2.sh shServerPortRandom)
export npm_config_mode_auto_restart=1
./lib.utility2.sh test test.js
return
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,5 @@
"test": "./npm_scripts.sh",
"utility2": "./npm_scripts.sh"
},
"version": "2019.9.7"
"version": "2019.10.8"
}
Loading

0 comments on commit f0eadff

Please sign in to comment.