@tko/utils.functionrewrite 4.0.0-alpha8.2 → 4.0.0-beta1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/functionRewrite.js +14 -0
- package/dist/functionRewrite.js.map +7 -0
- package/dist/index.cjs +40 -0
- package/dist/index.cjs.map +7 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +7 -0
- package/dist/index.mjs +2 -0
- package/dist/index.mjs.map +7 -0
- package/package.json +19 -21
- package/dist/utils.functionrewrite.es6.js +0 -26
- package/dist/utils.functionrewrite.es6.js.map +0 -1
- package/dist/utils.functionrewrite.js +0 -24
- package/dist/utils.functionrewrite.js.map +0 -1
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
// @tko/utils.functionrewrite 🥊 4.0.0-beta1.0 ESM
|
|
2
|
+
const FUNCTION_REX = /\bfunction\s*\(([^)]*)\)\s*\{\s*(?:(return\s)?([^}]+?)[;\s]*)?\}/g;
|
|
3
|
+
export default function functionRewrite(bindingString) {
|
|
4
|
+
return bindingString.replace(FUNCTION_REX, (match, args, returnKeyword, rv) => {
|
|
5
|
+
if (rv && !returnKeyword) {
|
|
6
|
+
rv += " && undefined";
|
|
7
|
+
}
|
|
8
|
+
const out = `(${args.trim()}) => ${rv}`;
|
|
9
|
+
if (!functionRewrite.silent) {
|
|
10
|
+
console.log(`Knockout: Replace "${match}" with "${out}"`);
|
|
11
|
+
}
|
|
12
|
+
return out;
|
|
13
|
+
});
|
|
14
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../src/functionRewrite.ts"],
|
|
4
|
+
"sourcesContent": ["/**\n * This is a BindingString subclass that converts `function () {}` to lambas,\n * for backwards compatibility.\n *\n */\n\nconst FUNCTION_REX = /\\bfunction\\s*\\(([^)]*)\\)\\s*\\{\\s*(?:(return\\s)?([^}]+?)[;\\s]*)?\\}/g\n\nexport default function functionRewrite (bindingString) {\n return bindingString\n .replace(FUNCTION_REX, (match, args, returnKeyword, rv) => {\n if (rv && !returnKeyword) {\n rv += ' && undefined'\n }\n const out = `(${args.trim()}) => ${rv}`\n if (!functionRewrite.silent) {\n console.log(`Knockout: Replace \"${match}\" with \"${out}\"`)\n }\n return out\n })\n}\n"],
|
|
5
|
+
"mappings": ";AAMA,MAAM,eAAe;AAErB,wCAAyC,eAAe;AACtD,SAAO,cACJ,QAAQ,cAAc,CAAC,OAAO,MAAM,eAAe,OAAO;AACzD,QAAI,MAAM,CAAC,eAAe;AACxB,YAAM;AAAA,IACR;AACA,UAAM,MAAM,IAAI,KAAK,KAAK,SAAS;AACnC,QAAI,CAAC,gBAAgB,QAAQ;AAC3B,cAAQ,IAAI,sBAAsB,gBAAgB,MAAM;AAAA,IAC1D;AACA,WAAO;AAAA,EACX,CAAC;AACH;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// @tko/utils.functionrewrite 🥊 4.0.0-beta1.0 CommonJS
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// index.ts
|
|
21
|
+
var utils_exports = {};
|
|
22
|
+
__export(utils_exports, {
|
|
23
|
+
functionRewrite: () => functionRewrite
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(utils_exports);
|
|
26
|
+
|
|
27
|
+
// src/functionRewrite.ts
|
|
28
|
+
var FUNCTION_REX = /\bfunction\s*\(([^)]*)\)\s*\{\s*(?:(return\s)?([^}]+?)[;\s]*)?\}/g;
|
|
29
|
+
function functionRewrite(bindingString) {
|
|
30
|
+
return bindingString.replace(FUNCTION_REX, (match, args, returnKeyword, rv) => {
|
|
31
|
+
if (rv && !returnKeyword) {
|
|
32
|
+
rv += " && undefined";
|
|
33
|
+
}
|
|
34
|
+
const out = `(${args.trim()}) => ${rv}`;
|
|
35
|
+
if (!functionRewrite.silent) {
|
|
36
|
+
console.log(`Knockout: Replace "${match}" with "${out}"`);
|
|
37
|
+
}
|
|
38
|
+
return out;
|
|
39
|
+
});
|
|
40
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../index.ts", "../src/functionRewrite.ts"],
|
|
4
|
+
"sourcesContent": ["export * from './src'\n", "/**\n * This is a BindingString subclass that converts `function () {}` to lambas,\n * for backwards compatibility.\n *\n */\n\nconst FUNCTION_REX = /\\bfunction\\s*\\(([^)]*)\\)\\s*\\{\\s*(?:(return\\s)?([^}]+?)[;\\s]*)?\\}/g\n\nexport default function functionRewrite (bindingString) {\n return bindingString\n .replace(FUNCTION_REX, (match, args, returnKeyword, rv) => {\n if (rv && !returnKeyword) {\n rv += ' && undefined'\n }\n const out = `(${args.trim()}) => ${rv}`\n if (!functionRewrite.silent) {\n console.log(`Knockout: Replace \"${match}\" with \"${out}\"`)\n }\n return out\n })\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACMA,IAAM,eAAe;AAEN,yBAA0B,eAAe;AACtD,SAAO,cACJ,QAAQ,cAAc,CAAC,OAAO,MAAM,eAAe,OAAO;AACzD,QAAI,MAAM,CAAC,eAAe;AACxB,YAAM;AAAA,IACR;AACA,UAAM,MAAM,IAAI,KAAK,KAAK,SAAS;AACnC,QAAI,CAAC,gBAAgB,QAAQ;AAC3B,cAAQ,IAAI,sBAAsB,gBAAgB,MAAM;AAAA,IAC1D;AACA,WAAO;AAAA,EACX,CAAC;AACH;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
package/dist/index.js
ADDED
package/dist/index.mjs
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
|
+
"version": "4.0.0-beta1.0",
|
|
2
3
|
"name": "@tko/utils.functionrewrite",
|
|
3
|
-
"version": "4.0.0-alpha8.2",
|
|
4
4
|
"description": "Rewrite `function {}` as lambdas (=>)",
|
|
5
5
|
"module": "dist/utils.functionrewrite.js",
|
|
6
6
|
"files": [
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
],
|
|
10
10
|
"license": "MIT",
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"tslib": "^
|
|
12
|
+
"tslib": "^2.2.0"
|
|
13
13
|
},
|
|
14
14
|
"karma": {
|
|
15
15
|
"frameworks": [
|
|
@@ -17,29 +17,27 @@
|
|
|
17
17
|
"chai"
|
|
18
18
|
]
|
|
19
19
|
},
|
|
20
|
-
"__about__shared.package.json": "These properties are copied into all packages/*/package.json. Run `yarn repackage`",
|
|
21
|
-
"standard": {
|
|
22
|
-
"env": [
|
|
23
|
-
"browser",
|
|
24
|
-
"jasmine",
|
|
25
|
-
"mocha"
|
|
26
|
-
]
|
|
27
|
-
},
|
|
28
|
-
"scripts": {
|
|
29
|
-
"test": "npx karma start ../../karma.conf.js --once",
|
|
30
|
-
"build": "npx rollup -c ../../rollup.config.js",
|
|
31
|
-
"watch": "npx karma start ../../karma.conf.js",
|
|
32
|
-
"prepare": "npx rollup -c ../../rollup.config.js"
|
|
33
|
-
},
|
|
34
|
-
"publishConfig": {
|
|
35
|
-
"access": "public"
|
|
36
|
-
},
|
|
37
20
|
"homepage": "https://tko.io",
|
|
38
21
|
"licenses": [
|
|
39
22
|
{
|
|
40
23
|
"type": "MIT",
|
|
41
|
-
"url": "
|
|
24
|
+
"url": "https://opensource.org/licenses/MIT"
|
|
42
25
|
}
|
|
43
26
|
],
|
|
44
|
-
"
|
|
27
|
+
"exports": {
|
|
28
|
+
".": {
|
|
29
|
+
"require": "./dist/index.cjs",
|
|
30
|
+
"import": "./dist/index.js"
|
|
31
|
+
},
|
|
32
|
+
"./helpers/*": "./helpers/*"
|
|
33
|
+
},
|
|
34
|
+
"bugs": {
|
|
35
|
+
"url": "https://github.com/knockout/tko/issues"
|
|
36
|
+
},
|
|
37
|
+
"author": "The Knockout Team",
|
|
38
|
+
"repository": {
|
|
39
|
+
"type": "git",
|
|
40
|
+
"url": "git+https://github.com/knockout/tko.git"
|
|
41
|
+
},
|
|
42
|
+
"gitHead": "99114c4deded3fc5dbddd5c7c9c63c845a18263b"
|
|
45
43
|
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Rewrite `function {}` as lambdas (=>) 🥊 @tko/utils.functionrewrite@4.0.0-alpha8.2
|
|
3
|
-
* (c) The Knockout.js Team - https://tko.io
|
|
4
|
-
* License: MIT (http://www.opensource.org/licenses/mit-license.php)
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* This is a BindingString subclass that converts `function () {}` to lambas,
|
|
9
|
-
* for backwards compatibility.
|
|
10
|
-
*
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
const FUNCTION_REX = /\bfunction\s*\(([^)]*)\)\s*{\s*(?:return\s+([^}]+?)\s*)?}/g;
|
|
14
|
-
|
|
15
|
-
function functionRewrite (bindingString) {
|
|
16
|
-
return bindingString
|
|
17
|
-
.replace(FUNCTION_REX, (match, args, rv) => {
|
|
18
|
-
if (!functionRewrite.silent) {
|
|
19
|
-
console.log(`Knockout: Replace "${match}" with "=> ${rv}"`);
|
|
20
|
-
}
|
|
21
|
-
return `(${args.trim()}) => ${rv}`
|
|
22
|
-
})
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export { functionRewrite };
|
|
26
|
-
//# sourceMappingURL=utils.functionrewrite.es6.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.functionrewrite.es6.js","sources":["../src/functionRewrite.js"],"sourcesContent":["/**\n * This is a BindingString subclass that converts `function () {}` to lambas,\n * for backwards compatibility.\n *\n */\n\nconst FUNCTION_REX = /\\bfunction\\s*\\(([^)]*)\\)\\s*{\\s*(?:return\\s+([^}]+?)\\s*)?}/g\n\nexport default function functionRewrite (bindingString) {\n return bindingString\n .replace(FUNCTION_REX, (match, args, rv) => {\n if (!functionRewrite.silent) {\n console.log(`Knockout: Replace \"${match}\" with \"=> ${rv}\"`)\n }\n return `(${args.trim()}) => ${rv}`\n })\n}\n"],"names":[],"mappings":";;;;;;AAAA;;;;;;AAMA,MAAM,YAAY,GAAG,6DAA4D;;AAEjF,SAAwB,eAAe,EAAE,aAAa,EAAE;EACtD,OAAO,aAAa;KACjB,OAAO,CAAC,YAAY,EAAE,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,KAAK;IAC5C,IAAI,CAAC,eAAe,CAAC,MAAM,EAAE;MAC3B,OAAO,CAAC,GAAG,CAAC,CAAC,mBAAmB,EAAE,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,CAAC,EAAC;KAC5D;IACD,OAAO,CAAC,CAAC,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;GACnC,CAAC;CACH;;"}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* Rewrite `function {}` as lambdas (=>) 🥊 @tko/utils.functionrewrite@4.0.0-alpha8.2
|
|
3
|
-
* (c) The Knockout.js Team - https://tko.io
|
|
4
|
-
* License: MIT (http://www.opensource.org/licenses/mit-license.php)
|
|
5
|
-
*/
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* This is a BindingString subclass that converts `function () {}` to lambas,
|
|
9
|
-
* for backwards compatibility.
|
|
10
|
-
*
|
|
11
|
-
*/
|
|
12
|
-
var FUNCTION_REX = /\bfunction\s*\(([^)]*)\)\s*{\s*(?:return\s+([^}]+?)\s*)?}/g;
|
|
13
|
-
function functionRewrite(bindingString) {
|
|
14
|
-
return bindingString
|
|
15
|
-
.replace(FUNCTION_REX, function (match, args, rv) {
|
|
16
|
-
if (!functionRewrite.silent) {
|
|
17
|
-
console.log("Knockout: Replace \"" + match + "\" with \"=> " + rv + "\"");
|
|
18
|
-
}
|
|
19
|
-
return "(" + args.trim() + ") => " + rv;
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export { functionRewrite };
|
|
24
|
-
//# sourceMappingURL=utils.functionrewrite.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.functionrewrite.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;"}
|