Comparing version 2.0.3 to 2.0.4
@@ -6,26 +6,21 @@ "use strict"; | ||
}); | ||
Object.defineProperty(exports, "laravel2js", { | ||
exports.default = void 0; | ||
Object.defineProperty(exports, "js2laravel", { | ||
enumerable: true, | ||
get: function get() { | ||
return _laravel2js.default; | ||
return _js2laravel.default; | ||
} | ||
}); | ||
Object.defineProperty(exports, "js2laravel", { | ||
Object.defineProperty(exports, "laravel2js", { | ||
enumerable: true, | ||
get: function get() { | ||
return _js2laravel.default; | ||
return _laravel2js.default; | ||
} | ||
}); | ||
exports.default = void 0; | ||
var _laravel2js = _interopRequireDefault(require("./laravel2js.js")); | ||
var _js2laravel = _interopRequireDefault(require("./js2laravel.js")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var _default = { | ||
var _default = exports.default = { | ||
laravel2js: _laravel2js.default, | ||
js2laravel: _js2laravel.default | ||
}; | ||
exports.default = _default; | ||
}; |
@@ -7,9 +7,6 @@ "use strict"; | ||
exports.default = js2laravel; | ||
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } | ||
var js2laravelClb = function js2laravelClb(resources, cb) { | ||
var result = "<?php\n return ["; | ||
var end = ' ];'; | ||
(function stringifyJs(obj, level) { | ||
@@ -20,3 +17,2 @@ if (obj) { | ||
var value = obj[key] || ''; | ||
if (typeof value === 'string') { | ||
@@ -26,3 +22,2 @@ value = value.replace(/'/g, '\\\''); | ||
} | ||
if (_typeof(value) === 'object') { | ||
@@ -33,3 +28,2 @@ result += "\n ".concat(' '.repeat(level), "'").concat(key, "' => ["); | ||
} | ||
if (index + 1 < keys.length) { | ||
@@ -41,3 +35,2 @@ result += ','; | ||
})(resources, 1); | ||
result += "\n".concat(end); | ||
@@ -47,3 +40,2 @@ if (cb) return cb(null, result); | ||
}; | ||
function js2laravel(resources, cb) { | ||
@@ -57,6 +49,4 @@ if (!cb) { | ||
} | ||
return js2laravelClb(resources, cb); | ||
} | ||
module.exports = exports.default; |
@@ -7,7 +7,4 @@ "use strict"; | ||
exports.default = laravel2js; | ||
var _phpParser = _interopRequireDefault(require("php-parser")); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var laravel2jsClb = function laravel2jsClb(str, cb) { | ||
@@ -19,3 +16,2 @@ if (typeof str !== 'string') { | ||
} | ||
var parser = new _phpParser.default({ | ||
@@ -30,7 +26,5 @@ parser: { | ||
}); | ||
try { | ||
var result = {}; | ||
var ast = parser.parseCode(str); | ||
if (ast && ast.children && ast.children.length > 0) { | ||
@@ -40,6 +34,4 @@ var returnElem = ast.children.find(function (ele) { | ||
}); | ||
if (returnElem && returnElem.expr && returnElem.expr.kind === 'array' && returnElem.expr.items) { | ||
; | ||
(function parseArr(items, parent) { | ||
@@ -51,3 +43,2 @@ items.forEach(function (item) { | ||
} | ||
if (item.value.kind === 'array' && item.value.items) { | ||
@@ -62,3 +53,2 @@ parent[item.key.value] = {}; | ||
} | ||
if (cb) return cb(null, result); | ||
@@ -71,3 +61,2 @@ return result; | ||
}; | ||
function laravel2js(str, cb) { | ||
@@ -81,6 +70,4 @@ if (!cb) { | ||
} | ||
return laravel2jsClb(str, cb); | ||
} | ||
module.exports = exports.default; |
@@ -1,7 +0,5 @@ | ||
function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); } | ||
var js2laravelClb = function js2laravelClb(resources, cb) { | ||
var result = "<?php\n return ["; | ||
var end = ' ];'; | ||
(function stringifyJs(obj, level) { | ||
@@ -12,3 +10,2 @@ if (obj) { | ||
var value = obj[key] || ''; | ||
if (typeof value === 'string') { | ||
@@ -18,3 +15,2 @@ value = value.replace(/'/g, '\\\''); | ||
} | ||
if (_typeof(value) === 'object') { | ||
@@ -25,3 +21,2 @@ result += "\n ".concat(' '.repeat(level), "'").concat(key, "' => ["); | ||
} | ||
if (index + 1 < keys.length) { | ||
@@ -33,3 +28,2 @@ result += ','; | ||
})(resources, 1); | ||
result += "\n".concat(end); | ||
@@ -39,3 +33,2 @@ if (cb) return cb(null, result); | ||
}; | ||
export default function js2laravel(resources, cb) { | ||
@@ -49,4 +42,3 @@ if (!cb) { | ||
} | ||
return js2laravelClb(resources, cb); | ||
} |
import Engine from 'php-parser'; | ||
var laravel2jsClb = function laravel2jsClb(str, cb) { | ||
@@ -9,3 +8,2 @@ if (typeof str !== 'string') { | ||
} | ||
var parser = new Engine({ | ||
@@ -20,7 +18,5 @@ parser: { | ||
}); | ||
try { | ||
var result = {}; | ||
var ast = parser.parseCode(str); | ||
if (ast && ast.children && ast.children.length > 0) { | ||
@@ -30,6 +26,4 @@ var returnElem = ast.children.find(function (ele) { | ||
}); | ||
if (returnElem && returnElem.expr && returnElem.expr.kind === 'array' && returnElem.expr.items) { | ||
; | ||
(function parseArr(items, parent) { | ||
@@ -41,3 +35,2 @@ items.forEach(function (item) { | ||
} | ||
if (item.value.kind === 'array' && item.value.items) { | ||
@@ -52,3 +45,2 @@ parent[item.key.value] = {}; | ||
} | ||
if (cb) return cb(null, result); | ||
@@ -61,3 +53,2 @@ return result; | ||
}; | ||
export default function laravel2js(str, cb) { | ||
@@ -71,4 +62,3 @@ if (!cb) { | ||
} | ||
return laravel2jsClb(str, cb); | ||
} |
const js2laravelClb = (resources, cb) => { | ||
var result = `<?php | ||
let result = `<?php | ||
return [` | ||
@@ -10,3 +10,3 @@ const end = ' ];' | ||
keys.forEach((key, index) => { | ||
var value = obj[key] || '' | ||
let value = obj[key] || '' | ||
if (typeof value === 'string') { | ||
@@ -13,0 +13,0 @@ value = value.replace(/'/g, '\\\'') |
@@ -21,3 +21,3 @@ import Engine from 'php-parser' | ||
try { | ||
var result = {} | ||
const result = {} | ||
const ast = parser.parseCode(str) | ||
@@ -24,0 +24,0 @@ if (ast && ast.children && ast.children.length > 0) { |
{ | ||
"name": "laravelphp", | ||
"version": "2.0.3", | ||
"version": "2.0.4", | ||
"description": "laravel2js and js2laravel converter laravel php resource utils", | ||
@@ -42,20 +42,20 @@ "type": "module", | ||
"dependencies": { | ||
"php-parser": "3.0.1" | ||
"php-parser": "3.1.5" | ||
}, | ||
"devDependencies": { | ||
"@babel/cli": "7.10.4", | ||
"@babel/core": "7.10.4", | ||
"@babel/preset-env": "7.10.4", | ||
"babel-plugin-add-module-exports": "1.0.2", | ||
"browserify": "16.5.1", | ||
"eslint": "7.3.1", | ||
"eslint-config-standard": "14.1.1", | ||
"eslint-plugin-import": "2.22.0", | ||
"@babel/cli": "7.23.0", | ||
"@babel/core": "7.23.2", | ||
"@babel/preset-env": "7.23.2", | ||
"babel-plugin-add-module-exports": "1.0.4", | ||
"browserify": "17.0.0", | ||
"eslint": "8.51.0", | ||
"eslint-config-standard": "17.1.0", | ||
"eslint-plugin-import": "2.28.1", | ||
"eslint-plugin-node": "11.1.0", | ||
"eslint-plugin-promise": "4.2.1", | ||
"eslint-plugin-promise": "6.1.1", | ||
"eslint-plugin-require-path-exists": "1.1.9", | ||
"eslint-plugin-standard": "4.0.1", | ||
"eslint-plugin-standard": "4.1.0", | ||
"expect.js": "0.3.1", | ||
"mocha": "8.0.1", | ||
"uglify-js": "3.10.0" | ||
"mocha": "10.2.0", | ||
"uglify-js": "3.17.4" | ||
}, | ||
@@ -62,0 +62,0 @@ "scripts": { |
@@ -16,3 +16,3 @@ [![travis](https://img.shields.io/travis/locize/laravelphp.svg)](https://travis-ci.org/locize/laravelphp) [![npm](https://img.shields.io/npm/v/laravelphp.svg)](https://npmjs.org/package/laravelphp) | ||
```js | ||
import resx from 'resx' | ||
import laravelphp from 'laravelphp' | ||
// or | ||
@@ -19,0 +19,0 @@ const laravelphp = require('laravelphp') |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
482932
10792
15
+ Addedphp-parser@3.1.5(transitive)
- Removedphp-parser@3.0.1(transitive)
Updatedphp-parser@3.1.5