Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

endent

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

endent - npm Package Compare versions

Comparing version 1.0.8 to 1.0.9

5

package.json
{
"name": "endent",
"version": "1.0.8",
"description": "➡️ ES6 string tag that endows suitable indentation",
"version": "1.0.9",
"description": "➡️ An ES6 string tag that makes indentation right",
"main": "dist/endent.js",

@@ -42,4 +42,5 @@ "files": [

"dedent": "^0.7.0",
"fast-json-parse": "^1.0.3",
"objectorarray": "^1.0.2"
}
}

162

README.md

@@ -14,60 +14,43 @@ # Endent [![stability][stability-image]][stability-index]

An ES6 string tag that endows suitable indentation. Generate pretty javascript template with dynamic json.
An ES6 string tag that makes indentation right. Based on [dedent](https://github.com/dmnd/dedent), endows more suitable indentation.
## Usage
## Advantage
### pretty object
```js
import dedent from "dedent"
import endent from "endent"
function usageExample () {
var someobj = {
contact: {
jack: 123456,
tom: 654321
},
color: "blue",
animals: [ "bear", "fish", "dog", "cat"]
}
var someobj = {
contact: {
jack: 123456,
tom: 654321
},
color: "blue"
}
var colors = ["red", "pink", "white"]
var somejson = '["bear", "fish", "dog", "cat"]'
var awfulTmpl = dedent`
module.exports = store
var awfulTmpl = dedent`
function store (state, emitter) {
state["someobj"] = ${JSON.stringify(someobj, null, 2)}
state["somejson"] = ${JSON.stringify(JSON.parse(somejson), null, 2)}
}
`
// use endent.pretty(value) when value is object or array.
var prettyTmpl = endent`
function store (state, emitter) {
state["someobj"] = ${endent.pretty(someobj)}
state["somejson"] = ${somejson}
}
`
function store (state, emitter) {
emitter.on("DOMContentLoaded", function () {
state["someobj"] = ${JSON.stringify(someobj, null, 2)}
state["colors"] = ${JSON.stringify(colors, null, 2)}
})
}
`
var prettyTmpl = endent`
module.exports = store
function store (state, emitter) {
emitter.on("DOMContentLoaded", function () {
state["someobj"] = ${endent.pretty(someobj)}
state["colors"] = ${endent.pretty(colors)}
})
}
`
return awfulTmpl + "\n\n" + prettyTmpl
}
console.log(awfulTmpl + "\n\n" + prettyTmpl)
```
```js
> console.log(usageExample())
```
```js
// awfulTmpl
module.exports = store
function store (state, emitter) {
emitter.on("DOMContentLoaded", function () {
state["someobj"] = {
function store (state, emitter) {
state["someobj"] = {
"contact": {

@@ -78,44 +61,71 @@ "jack": 123456,

"color": "blue",
"animals": [
"bear"
state["somejson"] = [
"bear",
"fish",
"dog"
]
}
state["colors"] = [
"red",
"pink"
]
})
}
// prettyTmpl
function store (state, emitter) {
state["someobj"] = {
"contact": {
"jack": 123456,
"tom": 654321
},
"color": "blue"
}
state["somejson"] = [
"bear",
"fish",
"dog",
"cat"
]
}
```
### endows suitable indentation for multiline interpolation
// prettyTmpl ~
```js
var dependencies = ['jquery', 'underscore', 'bootstrap']
var dependencyTmpl = ``
dependencies.forEach((d, i) => {
dependencyTmpl += `var ${d} = require("${d}")\n`
})
module.exports = store
var awfulTmpl = dedent`
;(function () {
${dependencyTmpl}
})()
`
function store (state, emitter) {
emitter.on("DOMContentLoaded", function () {
state["someobj"] = {
"contact": {
"jack": 123456,
"tom": 654321
},
"color": "blue",
"animals": [
"bear",
"fish",
"dog",
"cat"
]
}
state["colors"] = [
"red",
"pink",
"white"
]
})
}
var prettyTmpl = endent`
;(function () {
${dependencyTmpl}
})()
`
console.log(awfulTmpl + "\n\n" + prettyTmpl)
```
```
// awfulTmpl
;(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')
})()
```
## License
MIT
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc