replace-comments-x
Advanced tools
Comparing version 1.0.3 to 2.0.0
11
index.js
/** | ||
* @file Replace the comments in a string. | ||
* @version 1.0.3 | ||
* @version 2.0.0 | ||
* @author Xotic750 <Xotic750@gmail.com> | ||
@@ -12,4 +12,6 @@ * @copyright Xotic750 | ||
var isString = require('is-string'); | ||
var toStr = require('to-string-x'); | ||
var requireCoercibleToString = require('require-coercible-to-string-x'); | ||
var STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg; | ||
var replace = ''.replace; | ||
@@ -21,2 +23,4 @@ /** | ||
* @param {string} [replacement] - The string to be used as a replacement. | ||
* @throws {TypeError} If string is null or undefined or not coercible. | ||
* @throws {TypeError} If replacement is not coercible. | ||
* @returns {string} The new string with the comments replaced. | ||
@@ -30,4 +34,3 @@ * @example | ||
module.exports = function replaceComments(string) { | ||
var replacement = arguments.length > 1 && isString(arguments[1]) ? arguments[1] : ''; | ||
return isString(string) ? string.replace(STRIP_COMMENTS, replacement) : ''; | ||
return replace.call(requireCoercibleToString(string), STRIP_COMMENTS, arguments.length > 1 ? toStr(arguments[1]) : ''); | ||
}; |
(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.returnExports = 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(_dereq_,module,exports){ | ||
/** | ||
* @file Replace the comments in a string. | ||
* @version 1.0.3 | ||
* @version 2.0.0 | ||
* @author Xotic750 <Xotic750@gmail.com> | ||
@@ -13,4 +13,6 @@ * @copyright Xotic750 | ||
var isString = _dereq_('is-string'); | ||
var toStr = _dereq_('to-string-x'); | ||
var requireCoercibleToString = _dereq_('require-coercible-to-string-x'); | ||
var STRIP_COMMENTS = /((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg; | ||
var replace = ''.replace; | ||
@@ -22,2 +24,4 @@ /** | ||
* @param {string} [replacement] - The string to be used as a replacement. | ||
* @throws {TypeError} If string is null or undefined or not coercible. | ||
* @throws {TypeError} If replacement is not coercible. | ||
* @returns {string} The new string with the comments replaced. | ||
@@ -31,29 +35,261 @@ * @example | ||
module.exports = function replaceComments(string) { | ||
var replacement = arguments.length > 1 && isString(arguments[1]) ? arguments[1] : ''; | ||
return isString(string) ? string.replace(STRIP_COMMENTS, replacement) : ''; | ||
return replace.call(requireCoercibleToString(string), STRIP_COMMENTS, arguments.length > 1 ? toStr(arguments[1]) : ''); | ||
}; | ||
},{"is-string":2}],2:[function(_dereq_,module,exports){ | ||
},{"require-coercible-to-string-x":5,"to-string-x":7}],2:[function(_dereq_,module,exports){ | ||
/** | ||
* @file Checks if `value` is `null` or `undefined`. | ||
* @version 1.4.1 | ||
* @author Xotic750 <Xotic750@gmail.com> | ||
* @copyright Xotic750 | ||
* @license {@link <https://opensource.org/licenses/MIT> MIT} | ||
* @module is-nil-x | ||
*/ | ||
'use strict'; | ||
var strValue = String.prototype.valueOf; | ||
var tryStringObject = function tryStringObject(value) { | ||
try { | ||
strValue.call(value); | ||
return true; | ||
} catch (e) { | ||
return false; | ||
} | ||
var isUndefined = _dereq_('validate.io-undefined'); | ||
var isNull = _dereq_('lodash.isnull'); | ||
/** | ||
* Checks if `value` is `null` or `undefined`. | ||
* | ||
* @param {*} value - The value to check. | ||
* @returns {boolean} Returns `true` if `value` is nullish, else `false`. | ||
* @example | ||
* var isNil = require('is-nil-x'); | ||
* | ||
* isNil(null); // => true | ||
* isNil(void 0); // => true | ||
* isNil(NaN); // => false | ||
*/ | ||
module.exports = function isNil(value) { | ||
return isNull(value) || isUndefined(value); | ||
}; | ||
},{"lodash.isnull":4,"validate.io-undefined":8}],3:[function(_dereq_,module,exports){ | ||
'use strict'; | ||
var toStr = Object.prototype.toString; | ||
var strClass = '[object String]'; | ||
var hasToStringTag = typeof Symbol === 'function' && typeof Symbol.toStringTag === 'symbol'; | ||
var hasSymbols = typeof Symbol === 'function' && typeof Symbol() === 'symbol'; | ||
module.exports = function isString(value) { | ||
if (typeof value === 'string') { return true; } | ||
if (typeof value !== 'object') { return false; } | ||
return hasToStringTag ? tryStringObject(value) : toStr.call(value) === strClass; | ||
if (hasSymbols) { | ||
var symToStr = Symbol.prototype.toString; | ||
var symStringRegex = /^Symbol\(.*\)$/; | ||
var isSymbolObject = function isSymbolObject(value) { | ||
if (typeof value.valueOf() !== 'symbol') { return false; } | ||
return symStringRegex.test(symToStr.call(value)); | ||
}; | ||
module.exports = function isSymbol(value) { | ||
if (typeof value === 'symbol') { return true; } | ||
if (toStr.call(value) !== '[object Symbol]') { return false; } | ||
try { | ||
return isSymbolObject(value); | ||
} catch (e) { | ||
return false; | ||
} | ||
}; | ||
} else { | ||
module.exports = function isSymbol(value) { | ||
// this environment does not support Symbols. | ||
return false; | ||
}; | ||
} | ||
},{}],4:[function(_dereq_,module,exports){ | ||
/** | ||
* lodash 3.0.0 (Custom Build) <https://lodash.com/> | ||
* Build: `lodash modern modularize exports="npm" -o ./` | ||
* Copyright 2012-2015 The Dojo Foundation <http://dojofoundation.org/> | ||
* Based on Underscore.js 1.7.0 <http://underscorejs.org/LICENSE> | ||
* Copyright 2009-2015 Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors | ||
* Available under MIT license <https://lodash.com/license> | ||
*/ | ||
/** | ||
* Checks if `value` is `null`. | ||
* | ||
* @static | ||
* @memberOf _ | ||
* @category Lang | ||
* @param {*} value The value to check. | ||
* @returns {boolean} Returns `true` if `value` is `null`, else `false`. | ||
* @example | ||
* | ||
* _.isNull(null); | ||
* // => true | ||
* | ||
* _.isNull(void 0); | ||
* // => false | ||
*/ | ||
function isNull(value) { | ||
return value === null; | ||
} | ||
module.exports = isNull; | ||
},{}],5:[function(_dereq_,module,exports){ | ||
/** | ||
* @file Requires an argument is corecible then converts using ToString. | ||
* @version 1.0.0 | ||
* @author Xotic750 <Xotic750@gmail.com> | ||
* @copyright Xotic750 | ||
* @license {@link <https://opensource.org/licenses/MIT> MIT} | ||
* @module require-coercible-to-string-x | ||
*/ | ||
'use strict'; | ||
var requireObjectCoercible = _dereq_('require-object-coercible-x'); | ||
var toStr = _dereq_('to-string-x'); | ||
/** | ||
* This method requires an argument is corecible then converts using ToString. | ||
* | ||
* @param {*} value - The value to converted to a string. | ||
* @throws {TypeError} If value is null or undefined. | ||
* @returns {string} The value as a string. | ||
* @example | ||
* var requireCoercibleToString = require('require-coercible-to-string-x'); | ||
* | ||
* requireCoercibleToString(); // TypeError | ||
* requireCoercibleToString(null); // TypeError | ||
* requireCoercibleToString(Symbol('')); // TypeError | ||
* requireCoercibleToString(Object.create(null)); // TypeError | ||
* requireCoercibleToString(1); // '1' | ||
* requireCoercibleToString(true); // 'true' | ||
*/ | ||
module.exports = function requireCoercibleToString(value) { | ||
return toStr(requireObjectCoercible(value)); | ||
}; | ||
},{"require-object-coercible-x":6,"to-string-x":7}],6:[function(_dereq_,module,exports){ | ||
/** | ||
* @file ES6-compliant shim for RequireObjectCoercible. | ||
* @see {@link http://www.ecma-international.org/ecma-262/6.0/#sec-requireobjectcoercible|7.2.1 RequireObjectCoercible ( argument )} | ||
* @version 1.4.1 | ||
* @author Xotic750 <Xotic750@gmail.com> | ||
* @copyright Xotic750 | ||
* @license {@link <https://opensource.org/licenses/MIT> MIT} | ||
* @module require-object-coercible-x | ||
*/ | ||
'use strict'; | ||
var isNil = _dereq_('is-nil-x'); | ||
/** | ||
* The abstract operation RequireObjectCoercible throws an error if argument | ||
* is a value that cannot be converted to an Object using ToObject. | ||
* | ||
* @param {*} value - The `value` to check. | ||
* @throws {TypeError} If `value` is a `null` or `undefined`. | ||
* @returns {string} The `value`. | ||
* @example | ||
* var RequireObjectCoercible = require('require-object-coercible-x'); | ||
* | ||
* RequireObjectCoercible(); // TypeError | ||
* RequireObjectCoercible(null); // TypeError | ||
* RequireObjectCoercible('abc'); // 'abc' | ||
* RequireObjectCoercible(true); // true | ||
* RequireObjectCoercible(Symbol('foo')); // Symbol('foo') | ||
*/ | ||
module.exports = function RequireObjectCoercible(value) { | ||
if (isNil(value)) { | ||
throw new TypeError('Cannot call method on ' + value); | ||
} | ||
return value; | ||
}; | ||
},{"is-nil-x":2}],7:[function(_dereq_,module,exports){ | ||
/** | ||
* @file ES6-compliant shim for ToString. | ||
* @see {@link http://www.ecma-international.org/ecma-262/6.0/#sec-tostring|7.1.12 ToString ( argument )} | ||
* @version 1.4.2 | ||
* @author Xotic750 <Xotic750@gmail.com> | ||
* @copyright Xotic750 | ||
* @license {@link <https://opensource.org/licenses/MIT> MIT} | ||
* @module to-string-x | ||
*/ | ||
'use strict'; | ||
var castString = ''.constructor; | ||
var isSymbol = _dereq_('is-symbol'); | ||
/** | ||
* The abstract operation ToString converts argument to a value of type String. | ||
* | ||
* @param {*} value - The value to convert to a string. | ||
* @throws {TypeError} If `value` is a Symbol. | ||
* @returns {string} The converted value. | ||
* @example | ||
* var $toString = require('to-string-x'); | ||
* | ||
* $toString(); // 'undefined' | ||
* $toString(null); // 'null' | ||
* $toString('abc'); // 'abc' | ||
* $toString(true); // 'true' | ||
* $toString(Symbol('foo')); // TypeError | ||
* $toString(Symbol.iterator); // TypeError | ||
* $toString(Object(Symbol.iterator)); // TypeError | ||
* $toString(Object.create(null)); // TypeError | ||
*/ | ||
module.exports = function ToString(value) { | ||
if (isSymbol(value)) { | ||
throw new TypeError('Cannot convert a Symbol value to a string'); | ||
} | ||
return castString(value); | ||
}; | ||
},{"is-symbol":3}],8:[function(_dereq_,module,exports){ | ||
/** | ||
* | ||
* VALIDATE: undefined | ||
* | ||
* | ||
* DESCRIPTION: | ||
* - Validates if a value is undefined. | ||
* | ||
* | ||
* NOTES: | ||
* [1] | ||
* | ||
* | ||
* TODO: | ||
* [1] | ||
* | ||
* | ||
* LICENSE: | ||
* MIT | ||
* | ||
* Copyright (c) 2014. Athan Reines. | ||
* | ||
* | ||
* AUTHOR: | ||
* Athan Reines. kgryte@gmail.com. 2014. | ||
* | ||
*/ | ||
'use strict'; | ||
/** | ||
* FUNCTION: isUndefined( value ) | ||
* Validates if a value is undefined. | ||
* | ||
* @param {*} value - value to be validated | ||
* @returns {Boolean} boolean indicating whether value is undefined | ||
*/ | ||
function isUndefined( value ) { | ||
return value === void 0; | ||
} // end FUNCTION isUndefined() | ||
// EXPORTS // | ||
module.exports = isUndefined; | ||
},{}]},{},[1])(1) | ||
}); |
!function(f){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=f();else if("function"==typeof define&&define.amd)define([],f);else{("undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this).returnExports=f()}}(function(){return function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a="function"==typeof require&&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||e)},l,l.exports,e,t,n,r)}return n[o].exports}for(var i="function"==typeof require&&require,o=0;o<r.length;o++)s(r[o]);return s}({1:[function(_dereq_,module,exports){/** | ||
* @file Replace the comments in a string. | ||
* @version 1.0.3 | ||
* @version 2.0.0 | ||
* @author Xotic750 <Xotic750@gmail.com> | ||
@@ -9,2 +9,36 @@ * @copyright Xotic750 | ||
*/ | ||
"use strict";var isString=_dereq_("is-string"),STRIP_COMMENTS=/((\/\/.*$)|(\/\*[\s\S]*?\*\/))/gm;module.exports=function replaceComments(string){var replacement=arguments.length>1&&isString(arguments[1])?arguments[1]:"";return isString(string)?string.replace(STRIP_COMMENTS,replacement):""}},{"is-string":2}],2:[function(_dereq_,module,exports){"use strict";var strValue=String.prototype.valueOf,tryStringObject=function tryStringObject(value){try{return strValue.call(value),!0}catch(e){return!1}},toStr=Object.prototype.toString,hasToStringTag="function"==typeof Symbol&&"symbol"==typeof Symbol.toStringTag;module.exports=function isString(value){return"string"==typeof value||"object"==typeof value&&(hasToStringTag?tryStringObject(value):"[object String]"===toStr.call(value))}},{}]},{},[1])(1)}); | ||
"use strict";var toStr=_dereq_("to-string-x"),requireCoercibleToString=_dereq_("require-coercible-to-string-x"),STRIP_COMMENTS=/((\/\/.*$)|(\/\*[\s\S]*?\*\/))/gm,replace="".replace;module.exports=function replaceComments(string){return replace.call(requireCoercibleToString(string),STRIP_COMMENTS,arguments.length>1?toStr(arguments[1]):"")}},{"require-coercible-to-string-x":5,"to-string-x":7}],2:[function(_dereq_,module,exports){/** | ||
* @file Checks if `value` is `null` or `undefined`. | ||
* @version 1.4.1 | ||
* @author Xotic750 <Xotic750@gmail.com> | ||
* @copyright Xotic750 | ||
* @license {@link <https://opensource.org/licenses/MIT> MIT} | ||
* @module is-nil-x | ||
*/ | ||
"use strict";var isUndefined=_dereq_("validate.io-undefined"),isNull=_dereq_("lodash.isnull");module.exports=function isNil(value){return isNull(value)||isUndefined(value)}},{"lodash.isnull":4,"validate.io-undefined":8}],3:[function(_dereq_,module,exports){"use strict";var toStr=Object.prototype.toString;if("function"==typeof Symbol&&"symbol"==typeof Symbol()){var symToStr=Symbol.prototype.toString,symStringRegex=/^Symbol\(.*\)$/,isSymbolObject=function isSymbolObject(value){return"symbol"==typeof value.valueOf()&&symStringRegex.test(symToStr.call(value))};module.exports=function isSymbol(value){if("symbol"==typeof value)return!0;if("[object Symbol]"!==toStr.call(value))return!1;try{return isSymbolObject(value)}catch(e){return!1}}}else module.exports=function isSymbol(value){return!1}},{}],4:[function(_dereq_,module,exports){module.exports=function isNull(value){return null===value}},{}],5:[function(_dereq_,module,exports){/** | ||
* @file Requires an argument is corecible then converts using ToString. | ||
* @version 1.0.0 | ||
* @author Xotic750 <Xotic750@gmail.com> | ||
* @copyright Xotic750 | ||
* @license {@link <https://opensource.org/licenses/MIT> MIT} | ||
* @module require-coercible-to-string-x | ||
*/ | ||
"use strict";var requireObjectCoercible=_dereq_("require-object-coercible-x"),toStr=_dereq_("to-string-x");module.exports=function requireCoercibleToString(value){return toStr(requireObjectCoercible(value))}},{"require-object-coercible-x":6,"to-string-x":7}],6:[function(_dereq_,module,exports){/** | ||
* @file ES6-compliant shim for RequireObjectCoercible. | ||
* @see {@link http://www.ecma-international.org/ecma-262/6.0/#sec-requireobjectcoercible|7.2.1 RequireObjectCoercible ( argument )} | ||
* @version 1.4.1 | ||
* @author Xotic750 <Xotic750@gmail.com> | ||
* @copyright Xotic750 | ||
* @license {@link <https://opensource.org/licenses/MIT> MIT} | ||
* @module require-object-coercible-x | ||
*/ | ||
"use strict";var isNil=_dereq_("is-nil-x");module.exports=function RequireObjectCoercible(value){if(isNil(value))throw new TypeError("Cannot call method on "+value);return value}},{"is-nil-x":2}],7:[function(_dereq_,module,exports){/** | ||
* @file ES6-compliant shim for ToString. | ||
* @see {@link http://www.ecma-international.org/ecma-262/6.0/#sec-tostring|7.1.12 ToString ( argument )} | ||
* @version 1.4.2 | ||
* @author Xotic750 <Xotic750@gmail.com> | ||
* @copyright Xotic750 | ||
* @license {@link <https://opensource.org/licenses/MIT> MIT} | ||
* @module to-string-x | ||
*/ | ||
"use strict";var castString="".constructor,isSymbol=_dereq_("is-symbol");module.exports=function ToString(value){if(isSymbol(value))throw new TypeError("Cannot convert a Symbol value to a string");return castString(value)}},{"is-symbol":3}],8:[function(_dereq_,module,exports){"use strict";module.exports=function isUndefined(value){return void 0===value}},{}]},{},[1])(1)}); |
{ | ||
"name": "replace-comments-x", | ||
"version": "1.0.3", | ||
"version": "2.0.0", | ||
"description": "Replace the comments in a string.", | ||
@@ -33,3 +33,4 @@ "homepage": "https://github.com/Xotic750/replace-comments-x", | ||
"dependencies": { | ||
"is-string": "^1.0.4" | ||
"require-coercible-to-string-x": "^1.0.0", | ||
"to-string-x": "^1.4.2" | ||
}, | ||
@@ -36,0 +37,0 @@ "devDependencies": { |
@@ -26,3 +26,3 @@ <a href="https://travis-ci.org/Xotic750/replace-comments-x" | ||
**Version**: 1.0.3 | ||
**Version**: 2.0.0 | ||
**Author**: Xotic750 <Xotic750@gmail.com> | ||
@@ -38,3 +38,8 @@ **License**: [MIT](<https://opensource.org/licenses/MIT>) | ||
**Returns**: <code>string</code> - The new string with the comments replaced. | ||
**Throws**: | ||
- <code>TypeError</code> If string is null or undefined or not coercible. | ||
- <code>TypeError</code> If replacement is not coercible. | ||
| Param | Type | Description | | ||
@@ -41,0 +46,0 @@ | --- | --- | --- | |
Sorry, the diff of this file is not supported yet
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
27818
362
0
55
2
1
+ Addedto-string-x@^1.4.2
+ Addedcached-constructors-x@1.0.2(transitive)
+ Addedis-nil-x@1.4.2(transitive)
+ Addedis-symbol@1.0.4(transitive)
+ Addedlodash.isnull@3.0.0(transitive)
+ Addedrequire-coercible-to-string-x@1.0.2(transitive)
+ Addedrequire-object-coercible-x@1.4.3(transitive)
+ Addedto-string-x@1.4.5(transitive)
+ Addedvalidate.io-undefined@1.0.3(transitive)
- Removedis-string@^1.0.4
- Removedhas-tostringtag@1.0.2(transitive)
- Removedis-string@1.0.7(transitive)