Comparing version 1.0.2 to 2.0.0
@@ -1,5 +0,5 @@ | ||
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.multiline=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | ||
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.multiline = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | ||
'use strict'; | ||
module.exports = function (str) { | ||
var match = str.match(/^[ \t]*(?=\S)/gm); | ||
module.exports = str => { | ||
const match = str.match(/^[ \t]*(?=\S)/gm); | ||
@@ -10,8 +10,6 @@ if (!match) { | ||
var indent = Math.min.apply(Math, match.map(function (el) { | ||
return el.length; | ||
})); | ||
// 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'); | ||
var re = new RegExp('^[ \\t]{' + indent + '}', 'gm'); | ||
return indent > 0 ? str.replace(re, '') : str; | ||
@@ -22,9 +20,9 @@ }; | ||
'use strict'; | ||
var stripIndent = require('strip-indent'); | ||
const stripIndent = require('strip-indent'); | ||
// start matching after: comment start block => ! or @preserve => optional whitespace => newline | ||
// Start matching after: comment start block => ! or @preserve => optional whitespace => newline | ||
// stop matching before: last newline => optional whitespace => comment end block | ||
var reCommentContents = /\/\*!?(?:\@preserve)?[ \t]*(?:\r\n|\n)([\s\S]*?)(?:\r\n|\n)[ \t]*\*\//; | ||
const reCommentContents = /\/\*!?(?:@preserve)?[ \t]*(?:\r\n|\n)([\s\S]*?)(?:\r\n|\n)[ \t]*\*\//; | ||
var multiline = module.exports = function (fn) { | ||
const multiline = fn => { | ||
if (typeof fn !== 'function') { | ||
@@ -34,3 +32,3 @@ throw new TypeError('Expected a function'); | ||
var match = reCommentContents.exec(fn.toString()); | ||
const match = reCommentContents.exec(fn.toString()); | ||
@@ -44,7 +42,7 @@ if (!match) { | ||
multiline.stripIndent = function (fn) { | ||
return stripIndent(multiline(fn)); | ||
}; | ||
multiline.stripIndent = fn => stripIndent(multiline(fn)); | ||
module.exports = multiline; | ||
},{"strip-indent":1}]},{},[2])(2) | ||
}); |
16
index.js
'use strict'; | ||
var stripIndent = require('strip-indent'); | ||
const stripIndent = require('strip-indent'); | ||
// start matching after: comment start block => ! or @preserve => optional whitespace => newline | ||
// Start matching after: comment start block => ! or @preserve => optional whitespace => newline | ||
// stop matching before: last newline => optional whitespace => comment end block | ||
var reCommentContents = /\/\*!?(?:\@preserve)?[ \t]*(?:\r\n|\n)([\s\S]*?)(?:\r\n|\n)[ \t]*\*\//; | ||
const reCommentContents = /\/\*!?(?:@preserve)?[ \t]*(?:\r\n|\n)([\s\S]*?)(?:\r\n|\n)[ \t]*\*\//; | ||
var multiline = module.exports = function (fn) { | ||
const multiline = fn => { | ||
if (typeof fn !== 'function') { | ||
@@ -13,3 +13,3 @@ throw new TypeError('Expected a function'); | ||
var match = reCommentContents.exec(fn.toString()); | ||
const match = reCommentContents.exec(fn.toString()); | ||
@@ -23,4 +23,4 @@ if (!match) { | ||
multiline.stripIndent = function (fn) { | ||
return stripIndent(multiline(fn)); | ||
}; | ||
multiline.stripIndent = fn => stripIndent(multiline(fn)); | ||
module.exports = multiline; |
{ | ||
"name": "multiline", | ||
"version": "1.0.2", | ||
"description": "Multiline strings in JavaScript", | ||
"license": "MIT", | ||
"repository": "sindresorhus/multiline", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "http://sindresorhus.com" | ||
}, | ||
"engines": { | ||
"node": ">=0.10.0" | ||
}, | ||
"scripts": { | ||
"test": "mocha", | ||
"browser": "browserify -s $npm_package_name -o browser.js ." | ||
}, | ||
"files": [ | ||
"index.js", | ||
"browser.js" | ||
], | ||
"keywords": [ | ||
"browser", | ||
"multiline", | ||
"multi-line", | ||
"multiple", | ||
"line", | ||
"comment", | ||
"string", | ||
"str", | ||
"text", | ||
"comment" | ||
], | ||
"dependencies": { | ||
"strip-indent": "^1.0.0" | ||
}, | ||
"devDependencies": { | ||
"browserify": "^6.0.2", | ||
"callsites": "^1.0.0", | ||
"mocha": "*", | ||
"uglify-js": "^2.4.13" | ||
} | ||
"name": "multiline", | ||
"version": "2.0.0", | ||
"description": "Multiline strings in JavaScript", | ||
"license": "MIT", | ||
"repository": "sindresorhus/multiline", | ||
"author": { | ||
"name": "Sindre Sorhus", | ||
"email": "sindresorhus@gmail.com", | ||
"url": "sindresorhus.com" | ||
}, | ||
"engines": { | ||
"node": ">=0.10.0" | ||
}, | ||
"scripts": { | ||
"test": "mocha", | ||
"browser": "browserify -s $npm_package_name -o browser.js ." | ||
}, | ||
"files": [ | ||
"index.js", | ||
"browser.js" | ||
], | ||
"keywords": [ | ||
"browser", | ||
"multiline", | ||
"multi-line", | ||
"multiple", | ||
"line", | ||
"comment", | ||
"string", | ||
"str", | ||
"text", | ||
"comment" | ||
], | ||
"dependencies": { | ||
"strip-indent": "^2.0.0" | ||
}, | ||
"devDependencies": { | ||
"browserify": "^14.5.0", | ||
"callsites": "^2.0.0", | ||
"mocha": "^4.1.0", | ||
"uglify-js": "^2.4.13" | ||
} | ||
} |
@@ -7,3 +7,3 @@ # multiline [![Build Status](https://travis-ci.org/sindresorhus/multiline.svg?branch=master)](https://travis-ci.org/sindresorhus/multiline) | ||
*Note that ES6 will have [template string](http://www.2ality.com/2011/09/quasi-literals.html) which can be multiline, but time...* | ||
*Use ES2015 [template literals](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/template_strings) instead whenever possible.* | ||
@@ -13,3 +13,3 @@ #### Before | ||
```js | ||
var str = '' + | ||
const str = '' + | ||
'<!doctype html>' + | ||
@@ -27,3 +27,3 @@ '<html>' + | ||
```js | ||
var str = multiline(function(){/* | ||
const str = multiline(()=>{/* | ||
<!doctype html> | ||
@@ -48,5 +48,5 @@ <html> | ||
```sh | ||
$ npm install --save multiline | ||
``` | ||
$ npm install multiline | ||
``` | ||
@@ -59,3 +59,3 @@ | ||
```js | ||
var str = multiline(function(){/* | ||
const str = multiline(()=>{/* | ||
<!doctype html> | ||
@@ -86,3 +86,3 @@ <html> | ||
```js | ||
var str = multiline.stripIndent(function(){/* | ||
const str = multiline.stripIndent(()=>{/* | ||
<!doctype html> | ||
@@ -114,9 +114,9 @@ <html> | ||
```js | ||
var str = 'unicorns'; | ||
const str = 'unicorns'; | ||
console.log(multiline(function(){/* | ||
console.log(multiline(()=>{/* | ||
I love %s | ||
*/}), str); | ||
//=> I love unicorns | ||
//=> 'I love unicorns' | ||
``` | ||
@@ -142,3 +142,3 @@ | ||
```js | ||
var str = multiline(/* | ||
const str = multiline(/* | ||
<!doctype html> | ||
@@ -159,3 +159,3 @@ <html> | ||
```js | ||
var str = 'foo\ | ||
const str = 'foo\ | ||
bar'; | ||
@@ -169,3 +169,3 @@ ``` | ||
```js | ||
var str = 'foo\n\ | ||
const str = 'foo\n\ | ||
bar'; | ||
@@ -177,9 +177,7 @@ ``` | ||
```js | ||
var str = 'foo\n' + | ||
const str = 'foo\n' + | ||
'bar'; | ||
``` | ||
*Note that ES6 will have real [multiline strings](https://github.com/lukehoban/es6features#template-strings).* | ||
## Browser | ||
@@ -189,15 +187,9 @@ | ||
### Install | ||
```sh | ||
$ npm install --save multiline | ||
``` | ||
$ npm install multiline | ||
``` | ||
*(with [Browserify](http://browserify.org))* | ||
With Webpack, Browserify, or something similar. | ||
```sh | ||
$ bower install --save multiline | ||
``` | ||
### Compatibility | ||
@@ -224,3 +216,3 @@ | ||
```js | ||
var str = multiline(function(){/*!@preserve | ||
const str = multiline(function(){/*!@preserve | ||
<!doctype html> | ||
@@ -238,2 +230,2 @@ <html> | ||
MIT © [Sindre Sorhus](http://sindresorhus.com) | ||
MIT © [Sindre Sorhus](https://sindresorhus.com) |
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
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
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
8915
51
1
218
+ Addedstrip-indent@2.0.0(transitive)
- Removedget-stdin@4.0.1(transitive)
- Removedstrip-indent@1.0.1(transitive)
Updatedstrip-indent@^2.0.0