Comparing version 2.0.0 to 2.0.1
@@ -1,4 +0,9 @@ | ||
import dedent from "dedent"; | ||
import objectorarray from "objectorarray"; | ||
import parse from "fast-json-parse"; | ||
"use strict"; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
const dedent_1 = __importDefault(require("dedent")); | ||
const objectorarray_1 = __importDefault(require("objectorarray")); | ||
const fast_json_parse_1 = __importDefault(require("fast-json-parse")); | ||
const ENDENT_ID = "twhZNwxI1aFG3r4"; | ||
@@ -12,4 +17,4 @@ function endent(strings, ...values) { | ||
let isJson = false; | ||
if (parse(value).value) { | ||
value = parse(value).value; | ||
if (fast_json_parse_1.default(value).value) { | ||
value = fast_json_parse_1.default(value).value; | ||
isJson = true; | ||
@@ -55,10 +60,10 @@ } | ||
} | ||
result = dedent(result); | ||
result = dedent_1.default(result); | ||
return result.split(ENDENT_ID).join(""); | ||
} | ||
endent.pretty = (data) => { | ||
return objectorarray(data) | ||
return objectorarray_1.default(data) | ||
? { [ENDENT_ID]: JSON.stringify(data, null, 2) } | ||
: data; | ||
}; | ||
export default endent; | ||
exports.default = endent; |
{ | ||
"name": "endent", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "➡️ An ES6 string tag that makes indentation right", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
# Endent [![stability][stability-image]][stability-index] | ||
[![npm][npm-image]][npm-url] | ||
@@ -21,7 +22,7 @@ [![travis][travis-image]][travis-url] | ||
### pretty object | ||
### Pretty object | ||
```js | ||
import dedent from "dedent" | ||
import endent from "endent" | ||
```ts | ||
import dedent from "dedent"; | ||
import endent from "endent"; | ||
@@ -31,8 +32,8 @@ var someobj = { | ||
jack: 123456, | ||
tom: 654321 | ||
tom: 654321, | ||
}, | ||
color: "blue" | ||
} | ||
color: "blue", | ||
}; | ||
var somejson = '["bear", "fish", "dog", "cat"]' | ||
var somejson = '["bear", "fish", "dog", "cat"]'; | ||
@@ -44,3 +45,3 @@ var awfulTmpl = dedent` | ||
} | ||
` | ||
`; | ||
// use endent.pretty(value) when value is object or array. | ||
@@ -52,21 +53,22 @@ var prettyTmpl = endent` | ||
} | ||
` | ||
`; | ||
console.log(awfulTmpl + "\n\n" + prettyTmpl) | ||
console.log(awfulTmpl + "\n\n" + prettyTmpl); | ||
``` | ||
```js | ||
```ts | ||
// awfulTmpl | ||
function store (state, emitter) { | ||
function store(state, emitter) { | ||
state["someobj"] = { | ||
"contact": { | ||
"jack": 123456, | ||
"tom": 654321 | ||
contact: { | ||
jack: 123456, | ||
tom: 654321, | ||
}, | ||
"color": "blue" | ||
color: "blue", | ||
} | ||
state["somejson"] = [ | ||
"bear", | ||
"fish", | ||
"dog" | ||
"bear", | ||
"fish", | ||
"dog", | ||
"cat" | ||
] | ||
@@ -76,14 +78,14 @@ } | ||
// prettyTmpl | ||
function store (state, emitter) { | ||
function store(state, emitter) { | ||
state["someobj"] = { | ||
"contact": { | ||
"jack": 123456, | ||
"tom": 654321 | ||
contact: { | ||
jack: 123456, | ||
tom: 654321, | ||
}, | ||
"color": "blue" | ||
color: "blue", | ||
} | ||
state["somejson"] = [ | ||
"bear", | ||
"fish", | ||
"dog", | ||
"bear", | ||
"fish", | ||
"dog", | ||
"cat" | ||
@@ -94,10 +96,10 @@ ] | ||
### endows suitable indentation for multiline interpolation | ||
### Endows suitable indentation for multiline interpolation | ||
```js | ||
var dependencies = ['jquery', 'underscore', 'bootstrap'] | ||
var dependencyTmpl = `` | ||
```ts | ||
var dependencies = ["jquery", "underscore", "bootstrap"]; | ||
var dependencyTmpl = ``; | ||
dependencies.forEach((d, i) => { | ||
dependencyTmpl += `var ${d} = require("${d}")\n` | ||
}) | ||
dependencyTmpl += `var ${d} = require("${d}")\n`; | ||
}); | ||
@@ -108,3 +110,3 @@ var awfulTmpl = dedent` | ||
})() | ||
` | ||
`; | ||
@@ -115,5 +117,5 @@ var prettyTmpl = endent` | ||
})() | ||
` | ||
`; | ||
console.log(awfulTmpl + "\n\n" + prettyTmpl) | ||
console.log(awfulTmpl + "\n\n" + prettyTmpl); | ||
``` | ||
@@ -123,19 +125,18 @@ | ||
// awfulTmpl | ||
;(function () { | ||
var jquery = require('jquery') | ||
var underscore = require('underscore') | ||
var bootstrap = require('bootstrap') | ||
})() | ||
(function () { | ||
var jquery = require("jquery"); | ||
var underscore = require("underscore"); | ||
var bootstrap = require("bootstrap"); | ||
})(); | ||
// prettyTmpl | ||
;(function () { | ||
var jquery = require('jquery') | ||
var underscore = require('underscore') | ||
var bootstrap = require('bootstrap') | ||
})() | ||
(function () { | ||
var jquery = require("jquery"); | ||
var underscore = require("underscore"); | ||
var bootstrap = require("bootstrap"); | ||
})(); | ||
``` | ||
``` | ||
## License | ||
MIT |
{ | ||
"compilerOptions": { | ||
"target": "esnext", | ||
"module": "esnext", | ||
"module": "commonjs", | ||
"moduleResolution": "node", | ||
@@ -6,0 +6,0 @@ "esModuleInterop": true, |
Sorry, the diff of this file is not supported yet
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
283
134
0
11945
10