Skip to content

Commit

Permalink
feat: rewrite in TS, start using named exports
Browse files Browse the repository at this point in the history
  • Loading branch information
revelt committed Dec 25, 2020
1 parent df180c5 commit a00f311
Show file tree
Hide file tree
Showing 21 changed files with 284 additions and 104 deletions.
3 changes: 2 additions & 1 deletion packages/regex-empty-conditional-comments/.npmignore
@@ -1,4 +1,4 @@
# .... generated using www.npmjs.com/package/lect ....
# generated using codsen.com/os/lect
#
#
# __ ______ ______ ______
Expand All @@ -23,3 +23,4 @@ test
.prettierignore
rollup.config.js
testStats.md
tsconfig.json
2 changes: 1 addition & 1 deletion packages/regex-empty-conditional-comments/README.md
Expand Up @@ -34,7 +34,7 @@ npm i regex-empty-conditional-comments

```js
import { strict as assert } from "assert";
import emptyCondCommentRegex from "regex-empty-conditional-comments";
import { emptyCondCommentRegex } from "regex-empty-conditional-comments";

// empty comment which was meant to target Outlook-only
assert.equal(
Expand Down
@@ -1 +1 @@
{"total":{"lines":{"total":1,"covered":1,"skipped":0,"pct":100},"statements":{"total":2,"covered":2,"skipped":0,"pct":100},"functions":{"total":1,"covered":1,"skipped":0,"pct":100},"branches":{"total":0,"covered":0,"skipped":0,"pct":100}}}
{"total":{"lines":{"total":2,"covered":2,"skipped":0,"pct":100},"statements":{"total":2,"covered":2,"skipped":0,"pct":100},"functions":{"total":1,"covered":1,"skipped":0,"pct":100},"branches":{"total":0,"covered":0,"skipped":0,"pct":100}}}
Expand Up @@ -9,8 +9,13 @@

'use strict';

var main = (function () {
Object.defineProperty(exports, '__esModule', { value: true });

var version = "1.9.1";

function emptyCondCommentRegex() {
return /<!(--)?\[if[^\]]*]>[<>!-\s]*<!\[endif\]\1>/gi;
});
}

module.exports = main;
exports.emptyCondCommentRegex = emptyCondCommentRegex;
exports.version = version;
Expand Up @@ -8,15 +8,20 @@
*/

(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
typeof define === 'function' && define.amd ? define(factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, global.regexEmptyConditionalComments = factory());
}(this, (function () { 'use strict';
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
typeof define === 'function' && define.amd ? define(['exports'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.regexEmptyConditionalComments = {}));
}(this, (function (exports) { 'use strict';

var main = (function () {
return /<!(--)?\[if[^\]]*]>[<>!-\s]*<!\[endif\]\1>/gi;
});
var version = "1.9.1";

return main;
function emptyCondCommentRegex() {
return /<!(--)?\[if[^\]]*]>[<>!-\s]*<!\[endif\]\1>/gi;
}

exports.emptyCondCommentRegex = emptyCondCommentRegex;
exports.version = version;

Object.defineProperty(exports, '__esModule', { value: true });

})));
Expand Up @@ -7,6 +7,10 @@
* Homepage: https://codsen.com/os/regex-empty-conditional-comments/
*/

var main = () => /<!(--)?\[if[^\]]*]>[<>!-\s]*<!\[endif\]\1>/gi;
var version = "1.9.1";

export default main;
function emptyCondCommentRegex() {
return /<!(--)?\[if[^\]]*]>[<>!-\s]*<!\[endif\]\1>/gi;
}

export { emptyCondCommentRegex, version };
@@ -0,0 +1,10 @@
/**
* regex-empty-conditional-comments
* Regular expression for matching HTML empty conditional comments
* Version: 1.9.1
* Author: Roy Revelt, Codsen Ltd
* License: MIT
* Homepage: https://codsen.com/os/regex-empty-conditional-comments/
*/

var i="1.9.1";function n(){return/<!(--)?\[if[^\]]*]>[<>!-\s]*<!\[endif\]\1>/gi}export{n as emptyCondCommentRegex,i as version};
Expand Up @@ -7,4 +7,4 @@
* Homepage: https://codsen.com/os/regex-empty-conditional-comments/
*/

!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?module.exports=n():"function"==typeof define&&define.amd?define(n):(e="undefined"!=typeof globalThis?globalThis:e||self).regexEmptyConditionalComments=n()}(this,(function(){"use strict";return function(){return/<!(--)?\[if[^\]]*]>[<>!-\s]*<!\[endif\]\1>/gi}}));
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).regexEmptyConditionalComments={})}(this,(function(e){"use strict";e.emptyCondCommentRegex=function(){return/<!(--)?\[if[^\]]*]>[<>!-\s]*<!\[endif\]\1>/gi},e.version="1.9.1",Object.defineProperty(e,"__esModule",{value:!0})}));
@@ -1,9 +1,7 @@
/* eslint import/extensions:0 */

// Quick Take

import { strict as assert } from "assert";
import emptyCondCommentRegex from "../dist/regex-empty-conditional-comments.esm.js";
import { emptyCondCommentRegex } from "../dist/regex-empty-conditional-comments.esm.js";

// empty comment which was meant to target Outlook-only
assert.equal(
Expand Down
@@ -1 +1 @@
{"_quickTake.js":{"title":"Quick Take","content":"import &#x7B; strict as assert &#x7D; from \"assert\";\nimport emptyCondCommentRegex from \"regex-empty-conditional-comments\";\n\n// empty comment which was meant to target Outlook-only\nassert.equal(\n emptyCondCommentRegex().test(`<!--[if !mso]>\n<![endif]-->`),\n true\n);\n\n// empty comment which was meant to target non-Outlook-only\nassert.equal(\n emptyCondCommentRegex().test(`<!--[if !mso]><!-- -->\n<!--<![endif]-->`),\n true\n);\n\nassert.equal(\n emptyCondCommentRegex().test(`<!--[if !mso]><!-- -->\n<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\" />\n<!--<![endif]-->`),\n false\n);\n\nassert.equal(\n emptyCondCommentRegex().test(`<!--[if gte mso 9]><xml>\n<o:OfficeDocumentSettings>\n<o:AllowPNG/>\n<o:PixelsPerInch>96</o:PixelsPerInch>\n</o:OfficeDocumentSettings>\n</xml><![endif]-->`),\n false\n);\n\nassert.equal(\n emptyCondCommentRegex().exec(\"<html><!--[if !mso]><![endif]--><title>\")[0],\n \"<!--[if !mso]><![endif]-->\"\n);\n\nassert.deepEqual(\n `<html> <!--[if !mso]><![endif]--> <title>text</title> <!--[if gte mso 9]>\n<xml>\n<![endif]-->`.match(emptyCondCommentRegex()),\n [\"<!--[if !mso]><![endif]-->\"]\n);"}}
{"_quickTake.js":{"title":"Quick Take","content":"import &#x7B; strict as assert &#x7D; from \"assert\";\nimport &#x7B; emptyCondCommentRegex &#x7D; from \"regex-empty-conditional-comments\";\n\n// empty comment which was meant to target Outlook-only\nassert.equal(\n emptyCondCommentRegex().test(`<!--[if !mso]>\n<![endif]-->`),\n true\n);\n\n// empty comment which was meant to target non-Outlook-only\nassert.equal(\n emptyCondCommentRegex().test(`<!--[if !mso]><!-- -->\n<!--<![endif]-->`),\n true\n);\n\nassert.equal(\n emptyCondCommentRegex().test(`<!--[if !mso]><!-- -->\n<meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\" />\n<!--<![endif]-->`),\n false\n);\n\nassert.equal(\n emptyCondCommentRegex().test(`<!--[if gte mso 9]><xml>\n<o:OfficeDocumentSettings>\n<o:AllowPNG/>\n<o:PixelsPerInch>96</o:PixelsPerInch>\n</o:OfficeDocumentSettings>\n</xml><![endif]-->`),\n false\n);\n\nassert.equal(\n emptyCondCommentRegex().exec(\"<html><!--[if !mso]><![endif]--><title>\")[0],\n \"<!--[if !mso]><![endif]-->\"\n);\n\nassert.deepEqual(\n `<html> <!--[if !mso]><![endif]--> <title>text</title> <!--[if gte mso 9]>\n<xml>\n<![endif]-->`.match(emptyCondCommentRegex()),\n [\"<!--[if !mso]><![endif]-->\"]\n);"}}
3 changes: 0 additions & 3 deletions packages/regex-empty-conditional-comments/index.d.ts

This file was deleted.

4 changes: 0 additions & 4 deletions packages/regex-empty-conditional-comments/index.test-d.ts

This file was deleted.

63 changes: 28 additions & 35 deletions packages/regex-empty-conditional-comments/package.json
Expand Up @@ -27,16 +27,17 @@
"main": "dist/regex-empty-conditional-comments.cjs.js",
"module": "dist/regex-empty-conditional-comments.esm.js",
"browser": "dist/regex-empty-conditional-comments.umd.js",
"types": "index.d.ts",
"types": "types/main.d.ts",
"scripts": {
"build": "rollup -c",
"build": "npm run clean_types -- --pt1 && rollup -c && npm run clean_types -- --pt2",
"ci_test": "npm run build && npm run lint && tap --no-only --reporter=silent --output-file=testStats.md && npm run clean_cov && npm run format",
"clean_cov": "../../scripts/leaveCoverageTotalOnly.js",
"dev": "rollup -c --dev",
"clean_types": "../../scripts/cleanTypes.js",
"dev": "npm run clean_types -- --pt1 && rollup -c --dev && npm run clean_types -- --pt2",
"devunittest": "npm run dev && ./node_modules/.bin/tap --only -R 'base' && npm run tsd && npm run clean_cov",
"format": "npm run lect && npm run prettier && npm run lint",
"lect": "lect",
"lint": "../../node_modules/eslint/bin/eslint.js \"**/*.js\" --fix --config \"../../.eslintrc.json\" --quiet",
"lint": "../../node_modules/eslint/bin/eslint.js . --ext .js --ext .ts --fix --config \"../../.eslintrc.json\" --quiet",
"perf": "node perf/check",
"prepare": "npm run build",
"prettier": "../../node_modules/prettier/bin-prettier.js '*.{js,css,scss,vue,md,ts}' --write --loglevel silent",
Expand All @@ -45,15 +46,11 @@
"pretest": "npm run build",
"test": "npm run lint && npm run unittest && npm run test:examples && npm run clean_cov && npm run format",
"test:examples": "../../scripts/test-examples.js && npm run lect && npm run prettier",
"tsc": "tsc",
"tsd": "test ! -f index.d.ts || tsd",
"unittest": "./node_modules/.bin/tap --no-only --output-file=testStats.md --reporter=terse && npm run tsd && npm run clean_cov && npm run perf",
"unittest": "./node_modules/.bin/tap --no-only --output-file=testStats.md --reporter=terse && tsc --noEmit && npm run tsd && npm run clean_cov && npm run perf",
"version": "npm run build && git add ."
},
"husky": {
"hooks": {
"pre-commit": "npm run format && npm test"
}
},
"tap": {
"coverage-report": [
"json-summary",
Expand All @@ -66,58 +63,54 @@
"timeout": 0
},
"lect": {
"defaultExported": true,
"files": {
"delete": [],
"write_hard": [
{
"contents": "",
"name": ""
}
],
"write_soft": [
{
"contents": "",
"name": ""
}
]
},
"licence": {
"extras": [
""
]
},
"npmignore": {
"badFiles": [],
"badFolders": [],
"goodFiles": [],
"goodFolders": []
},
"req": "emptyCondCommentRegex",
"req": "{ emptyCondCommentRegex }",
"various": {
"devDependencies": []
}
},
"dependencies": {
"@babel/runtime": "^7.9.2"
},
"devDependencies": {
"@babel/cli": "^7.12.10",
"@babel/core": "^7.12.10",
"@babel/node": "^7.12.10",
"@babel/plugin-external-helpers": "^7.12.1",
"@babel/plugin-proposal-class-properties": "^7.12.1",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.12.1",
"@babel/plugin-proposal-object-rest-spread": "^7.12.1",
"@babel/plugin-proposal-optional-chaining": "^7.12.7",
"@babel/plugin-transform-runtime": "^7.12.10",
"@babel/preset-env": "^7.12.10",
"@babel/preset-typescript": "^7.12.7",
"@babel/register": "^7.12.10",
"@rollup/plugin-babel": "^5.2.2",
"@rollup/plugin-commonjs": "^17.0.0",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^11.0.1",
"@rollup/plugin-replace": "^2.3.4",
"@rollup/plugin-strip": "^2.0.0",
"benchmark": "^2.1.4",
"@rollup/plugin-typescript": "^8.1.0",
"@types/node": "^13.13.4",
"@types/tap": "^14.10.1",
"@typescript-eslint/eslint-plugin": "^4.11.0",
"@typescript-eslint/parser": "^4.11.0",
"eslint": "^7.15.0",
"fs-extra": "^9.0.1",
"lect": "^0.15.1",
"rollup": "^2.35.1",
"rollup-plugin-ascii": "^0.0.3",
"rollup-plugin-banner": "^0.2.1",
"rollup-plugin-cleanup": "^3.2.1",
"rollup-plugin-terser": "^7.0.2",
"tap": "^14.11.0",
"tsd": "^0.14.0"
"tsd": "^0.14.0",
"tslib": "^2.0.3",
"typescript": "^4.1.3"
}
}
4 changes: 2 additions & 2 deletions packages/regex-empty-conditional-comments/perf/check.js
Expand Up @@ -7,9 +7,9 @@ const callerDir = path.resolve(".");
const runPerf = require("../../../scripts/run-perf.js");

// setup
const f = require("..");
const { emptyCondCommentRegex } = require("..");

const testme = () => f();
const testme = () => emptyCondCommentRegex();

// action
runPerf(testme, callerDir);
Expand Up @@ -30,6 +30,7 @@
"1.8.54": 431298065.2659997,
"1.8.60": 854944820.0213381,
"1.9.0": 974419219.3978449,
"lastPublished": 974419219.3978449,
"lastRan": 974419219.3978449
"1.9.1": 839870381.5129391,
"lastPublished": 839870381.5129391,
"lastRan": 839870381.5129391
}

0 comments on commit a00f311

Please sign in to comment.