Comparing version 0.7.0 to 1.0.0
"use strict"; | ||
function dedent(strings) { | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
exports.default = dedent; | ||
// @flow | ||
var raw = void 0; | ||
if (typeof strings === "string") { | ||
// dedent can be used as a plain function | ||
raw = [strings]; | ||
} else { | ||
raw = strings.raw; | ||
} | ||
function dedent(strings /*: string | Array<string>*/, ...values /*: Array<string>*/) { | ||
// $FlowFixMe: Flow doesn't undestand .raw | ||
const raw = typeof strings === "string" ? [strings] : strings.raw; | ||
// first, perform interpolation | ||
var result = ""; | ||
for (var i = 0; i < raw.length; i++) { | ||
result += raw[i]. | ||
let result = ""; | ||
for (let i = 0; i < raw.length; i++) { | ||
result += raw[i] | ||
// join lines when there is a suppressed newline | ||
replace(/\\\n[ \t]*/g, ""). | ||
.replace(/\\\n[ \t]*/g, "") | ||
// handle escaped backticks | ||
replace(/\\`/g, "`"); | ||
if (i < (arguments.length <= 1 ? 0 : arguments.length - 1)) { | ||
result += arguments.length <= i + 1 ? undefined : arguments[i + 1]; | ||
.replace(/\\`/g, "`"); | ||
if (i < values.length) { | ||
result += values[i]; | ||
} | ||
@@ -29,8 +27,8 @@ } | ||
// now strip indentation | ||
var lines = result.split("\n"); | ||
var mindent = null; | ||
lines.forEach(function (l) { | ||
var m = l.match(/^(\s+)\S+/); | ||
const lines = result.split("\n"); | ||
let mindent /*: number | null*/ = null; | ||
lines.forEach(l => { | ||
let m = l.match(/^(\s+)\S+/); | ||
if (m) { | ||
var indent = m[1].length; | ||
let indent = m[1].length; | ||
if (!mindent) { | ||
@@ -44,18 +42,13 @@ // this is the first indented line | ||
}); | ||
if (mindent !== null) { | ||
result = lines.map(function (l) { | ||
return l[0] === " " ? l.slice(mindent) : l; | ||
}).join("\n"); | ||
const m = mindent; // appease Flow | ||
result = lines.map(l => l[0] === " " || l[0] === "\t" ? l.slice(m) : l).join("\n"); | ||
} | ||
return result | ||
// dedent eats leading and trailing whitespace too | ||
result = result.trim(); | ||
.trim() | ||
// handle escaped newlines at the end to ensure they don't get stripped too | ||
return result.replace(/\\n/g, "\n"); | ||
.replace(/\\n/g, "\n"); | ||
} | ||
if (typeof module !== "undefined") { | ||
module.exports = dedent; | ||
} | ||
module.exports = exports.default; | ||
module.exports.default = exports.default; |
{ | ||
"name": "dedent", | ||
"version": "0.7.0", | ||
"version": "1.0.0", | ||
"description": "An ES6 string tag that strips indentation from multi-line strings", | ||
"main": "dist/dedent.js", | ||
"module": "./dist/dedent.mjs", | ||
"files": [ | ||
"dist/dedent.js", | ||
"dist/dedent.mjs", | ||
"macro.js", | ||
"index.d.ts", | ||
"macro.d.ts", | ||
"README.md", | ||
"LICENSE" | ||
@@ -30,15 +36,26 @@ ], | ||
"homepage": "https://github.com/dmnd/dedent", | ||
"dependencies": { | ||
"babel-plugin-macros": "^3.1.0" | ||
}, | ||
"devDependencies": { | ||
"babel-cli": "^6.22.2", | ||
"babel-preset-es2015": "^6.22.0", | ||
"babel-preset-es2016": "^6.22.0", | ||
"babel-preset-es2017": "^6.22.0", | ||
"eslint": "^3.14.1", | ||
"jest": "^18.1.0" | ||
"@babel/cli": "^7.21.5", | ||
"@babel/core": "^7.21.8", | ||
"@babel/plugin-transform-flow-comments": "^7.22.5", | ||
"@babel/preset-env": "^7.21.5", | ||
"babel-plugin-add-module-exports": "^1.0.4", | ||
"babel-plugin-tester": "^11.0.4", | ||
"eslint": "^8.41.0", | ||
"eslint-plugin-ft-flow": "^2.0.3", | ||
"flow-bin": "^0.206.0", | ||
"hermes-eslint": "^0.11.1", | ||
"jest": "^29.5.0" | ||
}, | ||
"scripts": { | ||
"build": "babel dedent.js --out-file dist/dedent.js", | ||
"build": "yarn build:legacy && yarn build:modern", | ||
"build:legacy": "BABEL_ENV=legacy babel dedent.js --out-file dist/dedent.js", | ||
"build:modern": "BABEL_ENV=modern babel dedent.js --out-file dist/dedent.mjs", | ||
"lint": "eslint dedent.js __tests__", | ||
"prepack": "yarn build", | ||
"test": "jest" | ||
} | ||
} |
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
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
8151
8
120
0
1
11
1
+ Addedbabel-plugin-macros@^3.1.0
+ Added@babel/code-frame@7.26.2(transitive)
+ Added@babel/helper-validator-identifier@7.25.9(transitive)
+ Added@babel/runtime@7.26.0(transitive)
+ Added@types/parse-json@4.0.2(transitive)
+ Addedbabel-plugin-macros@3.1.0(transitive)
+ Addedcallsites@3.1.0(transitive)
+ Addedcosmiconfig@7.1.0(transitive)
+ Addederror-ex@1.3.2(transitive)
+ Addedfunction-bind@1.1.2(transitive)
+ Addedhasown@2.0.2(transitive)
+ Addedimport-fresh@3.3.0(transitive)
+ Addedis-arrayish@0.2.1(transitive)
+ Addedis-core-module@2.15.1(transitive)
+ Addedjs-tokens@4.0.0(transitive)
+ Addedjson-parse-even-better-errors@2.3.1(transitive)
+ Addedlines-and-columns@1.2.4(transitive)
+ Addedparent-module@1.0.1(transitive)
+ Addedparse-json@5.2.0(transitive)
+ Addedpath-parse@1.0.7(transitive)
+ Addedpath-type@4.0.0(transitive)
+ Addedpicocolors@1.1.1(transitive)
+ Addedregenerator-runtime@0.14.1(transitive)
+ Addedresolve@1.22.8(transitive)
+ Addedresolve-from@4.0.0(transitive)
+ Addedsupports-preserve-symlinks-flag@1.0.0(transitive)
+ Addedyaml@1.10.2(transitive)