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

dedent

Package Overview
Dependencies
Maintainers
2
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dedent - npm Package Compare versions

Comparing version 0.7.0 to 0.8.0-beta

dist/dedent.mjs

61

dist/dedent.js
"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": "0.8.0-beta",
"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"
}
}
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