Skip to content

Commit

Permalink
upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
CN-Tower committed Apr 6, 2021
1 parent 232f32c commit d653fd4
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 21 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

#### In HTML
```html
<script src="https://unpkg.com/format-to-json@2.0.1/fmt2json.min.js"></script>
<script src="https://unpkg.com/format-to-json@2.1.1/fmt2json.min.js"></script>
<script>
const source = `{"zjson":"ZJSON","description":"Online json formatter","version":"v4.1.8","updateTime":"2018-11-23","url":"http:https://zjson.net","project":"http:https://github.com/CN-Tower/zjson","language":["中文(简体)","English"],"keywords":["zjson","json formatter"],"content":{"array":["element 001","element 002"],"boolean":true,"null":null,"number":123,"string":"Hello World","object":{"property":"value","key":"val"}}}`;
(async () => {
Expand Down
10 changes: 5 additions & 5 deletions fmt2json.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @license
* format-to-json v2.0.1
* format-to-json v2.1.1
* GitHub Repository <https://github.com/CN-Tower/format-to-json>
* Released under MIT license <https://github.com/CN-Tower/format-to-json/blob/master/LICENSE>
*/
Expand Down Expand Up @@ -56,7 +56,7 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
* @param { object } options
* =================================================================
*/
function formatToJson(source, options) {
function fmt2json(source, options) {
return new Promise(function (resolve) {
/**
* The variables.
Expand Down Expand Up @@ -654,11 +654,11 @@ var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol
*/
if (typeof define === 'function' && define.amd) {
define(function () {
return formatToJson;
return fmt2json;
});
} else if ((typeof exports === 'undefined' ? 'undefined' : _typeof(exports)) === 'object') {
module.exports = formatToJson;
module.exports = fmt2json;
} else {
root.formatToJson = formatToJson;
root.fmt2json = fmt2json;
}
})(this);
4 changes: 2 additions & 2 deletions fmt2json.min.js

Large diffs are not rendered by default.

13 changes: 6 additions & 7 deletions test/index.html → index.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,19 @@
margin: 5px 10px 10px 0;
}
</style>
<script src="https://unpkg.com/[email protected]/fmt2json.min.js"></script>
</head>

<body>
<h2>format-to-json (v2.0.1)</h2>
<h2>format-to-json (v2.1.1)</h2>
<h4>Format a string to a json like template.</h4>
<div class="status">
<textarea id="status" name="result" id="" cols="84" rows="8" disabled></textarea>
</div>
<div class="content">
<div>
<label for="source">Format Source</label>&nbsp;&nbsp;
<button onclick="fmt2json()">Format</button><br>
<button onclick="formatToJson()">Format</button><br>
<textarea id="source" name="source" id="" cols="40" rows="30"></textarea><br>
</div>
<div>
Expand All @@ -49,17 +50,15 @@ <h4>Format a string to a json like template.</h4>
</div>
</div>

<script src="../fmt2json.min.js"></script>
<script>
const status = document.querySelector('#status');
const source = document.querySelector('#source');
const result = document.querySelector('#result');
source.value = '{"zjson":"ZJSON","description":"Online json formatter","version":"v4.1.8","updateTime":"2018-11-23","url":"http:https://zjson.net","project":"http:https://github.com/CN-Tower/zjson","language":["中文(简体)","English"],"keywords":["zjson","json formatter"],"content":{"array":["element 001","element 002"],"boolean":true,"null":null,"number":123,"string":"Hello World","object":{"property":"value","key":"val"}}}';

fmt2json();

async function fmt2json() {
const fmtInfo = await formatToJson(source.value);
formatToJson();
async function formatToJson() {
const fmtInfo = await fmt2json(source.value);
console.log(fmtInfo);
result.value = fmtInfo.result;
let fmtStatus = '';
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "format-to-json",
"version": "2.0.1",
"version": "2.1.1",
"description": "Format string to a json like template.",
"main": "index.js",
"bin": {
Expand Down
2 changes: 1 addition & 1 deletion scripts/license.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @license
* format-to-json v2.0.1
* format-to-json v2.1.1
* GitHub Repository <https://github.com/CN-Tower/format-to-json>
* Released under MIT license <https://github.com/CN-Tower/format-to-json/blob/master/LICENSE>
*/
8 changes: 4 additions & 4 deletions src/fmt2json.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
* @param { object } options
* =================================================================
*/
function formatToJson(source, options) {
function fmt2json(source, options) {
return new Promise(function(resolve) {
/**
* The variables.
Expand Down Expand Up @@ -622,12 +622,12 @@
*/
if (typeof define === 'function' && define.amd) {
define(function() {
return formatToJson;
return fmt2json;
});
} else if (typeof exports === 'object') {
module.exports = formatToJson;
module.exports = fmt2json;
} else {
root.formatToJson = formatToJson;
root.fmt2json = fmt2json;
}

}(this));

0 comments on commit d653fd4

Please sign in to comment.