46 lines
1.9 KiB
JavaScript
46 lines
1.9 KiB
JavaScript
!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){
|
|
'use strict';
|
|
module.exports = function (str) {
|
|
var match = str.match(/^[ \t]*(?=\S)/gm);
|
|
|
|
if (!match) {
|
|
return str;
|
|
}
|
|
|
|
var indent = Math.min.apply(Math, match.map(function (el) {
|
|
return el.length;
|
|
}));
|
|
|
|
var re = new RegExp('^[ \\t]{' + indent + '}', 'gm');
|
|
|
|
return indent > 0 ? str.replace(re, '') : str;
|
|
};
|
|
|
|
},{}],2:[function(require,module,exports){
|
|
'use strict';
|
|
var stripIndent = require('strip-indent');
|
|
|
|
// 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]*\*\//;
|
|
|
|
var multiline = module.exports = function (fn) {
|
|
if (typeof fn !== 'function') {
|
|
throw new TypeError('Expected a function');
|
|
}
|
|
|
|
var match = reCommentContents.exec(fn.toString());
|
|
|
|
if (!match) {
|
|
throw new TypeError('Multiline comment missing.');
|
|
}
|
|
|
|
return match[1];
|
|
};
|
|
|
|
multiline.stripIndent = function (fn) {
|
|
return stripIndent(multiline(fn));
|
|
};
|
|
|
|
},{"strip-indent":1}]},{},[2])(2)
|
|
}); |