Skip to content

Commit

Permalink
feat: rewrite in TS and start using named exports
Browse files Browse the repository at this point in the history
BREAKING CHANGE: previously: "import isJinjaSpecific from ..." - now "import { isJinjaSpecific }
from ..."
  • Loading branch information
revelt committed Dec 25, 2020
1 parent b5b44b7 commit 0764be7
Show file tree
Hide file tree
Showing 21 changed files with 326 additions and 114 deletions.
3 changes: 2 additions & 1 deletion packages/regex-jinja-specific/.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-jinja-specific/README.md
Expand Up @@ -34,7 +34,7 @@ npm i regex-jinja-specific

```js
import { strict as assert } from "assert";
import isJinjaSpecific from "regex-jinja-specific";
import { isJinjaSpecific } from "regex-jinja-specific";

assert.equal(
isJinjaSpecific().test(`<div>{{ '%.2f'|format(3.1415926) }}</div>`),
Expand Down
11 changes: 8 additions & 3 deletions packages/regex-jinja-specific/dist/regex-jinja-specific.cjs.js
Expand Up @@ -9,8 +9,13 @@

'use strict';

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

var version = "1.0.1";

function isJinjaSpecific() {
return /(set\s*[\w]+\s*=\s*namespace\()|({{['"][\w]+['"]\s+if)|(['"]%x?[+0]?[.>^<]?\d+[\w%]['"]\|format\()/gi;
});
}

module.exports = main;
exports.isJinjaSpecific = isJinjaSpecific;
exports.version = version;
21 changes: 13 additions & 8 deletions packages/regex-jinja-specific/dist/regex-jinja-specific.dev.umd.js
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.regexJinjaSpecific = 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.regexJinjaSpecific = {}));
}(this, (function (exports) { 'use strict';

var main = (function () {
return /(set\s*[\w]+\s*=\s*namespace\()|({{['"][\w]+['"]\s+if)|(['"]%x?[+0]?[.>^<]?\d+[\w%]['"]\|format\()/gi;
});
var version = "1.0.1";

return main;
function isJinjaSpecific() {
return /(set\s*[\w]+\s*=\s*namespace\()|({{['"][\w]+['"]\s+if)|(['"]%x?[+0]?[.>^<]?\d+[\w%]['"]\|format\()/gi;
}

exports.isJinjaSpecific = isJinjaSpecific;
exports.version = version;

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

})));
Expand Up @@ -7,7 +7,10 @@
* Homepage: https://codsen.com/os/regex-jinja-specific/
*/

var main = () =>
/(set\s*[\w]+\s*=\s*namespace\()|({{['"][\w]+['"]\s+if)|(['"]%x?[+0]?[.>^<]?\d+[\w%]['"]\|format\()/gi;
var version = "1.0.1";

export default main;
function isJinjaSpecific() {
return /(set\s*[\w]+\s*=\s*namespace\()|({{['"][\w]+['"]\s+if)|(['"]%x?[+0]?[.>^<]?\d+[\w%]['"]\|format\()/gi;
}

export { isJinjaSpecific, version };
10 changes: 10 additions & 0 deletions packages/regex-jinja-specific/dist/regex-jinja-specific.mjs
@@ -0,0 +1,10 @@
/**
* regex-jinja-specific
* Regular expression for detecting Python-specific Jinja code
* Version: 1.0.1
* Author: Roy Revelt, Codsen Ltd
* License: MIT
* Homepage: https://codsen.com/os/regex-jinja-specific/
*/

var s="1.0.1";function e(){return/(set\s*[\w]+\s*=\s*namespace\()|({{['"][\w]+['"]\s+if)|(['"]%x?[+0]?[.>^<]?\d+[\w%]['"]\|format\()/gi}export{e as isJinjaSpecific,s as version};
Expand Up @@ -7,4 +7,4 @@
* Homepage: https://codsen.com/os/regex-jinja-specific/
*/

!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).regexJinjaSpecific=n()}(this,(function(){"use strict";return function(){return/(set\s*[\w]+\s*=\s*namespace\()|({{['"][\w]+['"]\s+if)|(['"]%x?[+0]?[.>^<]?\d+[\w%]['"]\|format\()/gi}}));
!function(e,i){"object"==typeof exports&&"undefined"!=typeof module?i(exports):"function"==typeof define&&define.amd?define(["exports"],i):i((e="undefined"!=typeof globalThis?globalThis:e||self).regexJinjaSpecific={})}(this,(function(e){"use strict";e.isJinjaSpecific=function(){return/(set\s*[\w]+\s*=\s*namespace\()|({{['"][\w]+['"]\s+if)|(['"]%x?[+0]?[.>^<]?\d+[\w%]['"]\|format\()/gi},e.version="1.0.1",Object.defineProperty(e,"__esModule",{value:!0})}));
4 changes: 1 addition & 3 deletions packages/regex-jinja-specific/examples/_quickTake.js
@@ -1,9 +1,7 @@
/* eslint import/extensions:0 */

// Quick Take

import { strict as assert } from "assert";
import isJinjaSpecific from "../dist/regex-jinja-specific.esm.js";
import { isJinjaSpecific } from "../dist/regex-jinja-specific.esm.js";

assert.equal(
isJinjaSpecific().test(`<div>{{ '%.2f'|format(3.1415926) }}</div>`),
Expand Down
2 changes: 1 addition & 1 deletion packages/regex-jinja-specific/examples/api.json
@@ -1 +1 @@
{"_quickTake.js":{"title":"Quick Take","content":"import &#x7B; strict as assert &#x7D; from \"assert\";\nimport isJinjaSpecific from \"regex-jinja-specific\";\n\nassert.equal(\n isJinjaSpecific().test(`<div>&#x7B;&#x7B; '%.2f'|format(3.1415926) &#x7D;&#x7D;</div>`),\n true\n);\n\n// in case of ambiguous, Nunjucks-or-Jinja code\nassert.equal(isJinjaSpecific().test(`<div>&#x7B;&#x7B; value &#x7D;&#x7D;</div>`), false);"}}
{"_quickTake.js":{"title":"Quick Take","content":"import &#x7B; strict as assert &#x7D; from \"assert\";\nimport &#x7B; isJinjaSpecific &#x7D; from \"regex-jinja-specific\";\n\nassert.equal(\n isJinjaSpecific().test(`<div>&#x7B;&#x7B; '%.2f'|format(3.1415926) &#x7D;&#x7D;</div>`),\n true\n);\n\n// in case of ambiguous, Nunjucks-or-Jinja code\nassert.equal(isJinjaSpecific().test(`<div>&#x7B;&#x7B; value &#x7D;&#x7D;</div>`), false);"}}
3 changes: 0 additions & 3 deletions packages/regex-jinja-specific/index.d.ts

This file was deleted.

4 changes: 0 additions & 4 deletions packages/regex-jinja-specific/index.test-d.ts

This file was deleted.

63 changes: 28 additions & 35 deletions packages/regex-jinja-specific/package.json
Expand Up @@ -27,16 +27,17 @@
"main": "dist/regex-jinja-specific.cjs.js",
"module": "dist/regex-jinja-specific.esm.js",
"browser": "dist/regex-jinja-specific.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": "isJinjaSpecific",
"req": "{ isJinjaSpecific }",
"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-jinja-specific/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 { isJinjaSpecific } = require("..");

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

// action
runPerf(testme, callerDir);
5 changes: 3 additions & 2 deletions packages/regex-jinja-specific/perf/historical.json
@@ -1,5 +1,6 @@
{
"1.0.0": 838603014.0223383,
"lastPublished": 838603014.0223383,
"lastRan": 838603014.0223383
"1.0.1": 869555740.9914198,
"lastPublished": 869555740.9914198,
"lastRan": 869555740.9914198
}

0 comments on commit 0764be7

Please sign in to comment.