From 26105034da4fcce7ac883c899d781f016559310d Mon Sep 17 00:00:00 2001 From: ruki Date: Thu, 8 Nov 2018 00:38:48 +0800 Subject: switch to vuepress --- node_modules/strip-indent/index.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 node_modules/strip-indent/index.js (limited to 'node_modules/strip-indent/index.js') diff --git a/node_modules/strip-indent/index.js b/node_modules/strip-indent/index.js new file mode 100644 index 00000000..c90b2659 --- /dev/null +++ b/node_modules/strip-indent/index.js @@ -0,0 +1,14 @@ +'use strict'; +module.exports = str => { + const match = str.match(/^[ \t]*(?=\S)/gm); + + if (!match) { + return str; + } + + // TODO: use spread operator when targeting Node.js 6 + const indent = Math.min.apply(Math, match.map(x => x.length)); // eslint-disable-line + const re = new RegExp(`^[ \\t]{${indent}}`, 'gm'); + + return indent > 0 ? str.replace(re, '') : str; +}; -- cgit v1.2.3