clone-function
Advanced tools
Comparing version 1.0.5 to 1.0.6
@@ -1,2 +0,2 @@ | ||
;(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);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.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 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);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.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){ | ||
cloneFunction = require('../src/clone-function.js'); | ||
@@ -15,2 +15,3 @@ | ||
* Clones non native JavaScript functions, or references native functions. | ||
* @author <a href="mailto:matthewkastor@gmail.com">Matthew Kastor</a> | ||
* @param {Function} func The function to clone. | ||
@@ -21,7 +22,12 @@ * @returns {Function} Returns a clone of the non native function, or a | ||
function cloneFunction(func) { | ||
var out; | ||
if (/\[native code\]/.test(func.toString())) { | ||
out = func; | ||
} else { | ||
out = eval('(function(){return ' + func.toString() + '}());'); | ||
var out, str; | ||
try { | ||
str = func.toString(); | ||
if (/\[native code\]/.test(str)) { | ||
out = func; | ||
} else { | ||
out = eval('(function(){return ' + str + '}());'); | ||
} | ||
} catch (e) { | ||
throw new Error(e.message + '\r\n\r\n' + str); | ||
} | ||
@@ -32,3 +38,2 @@ return out; | ||
},{}]},{},[1]) | ||
//@ sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZ2VuZXJhdGVkLmpzIiwic291cmNlcy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1bmM7XHJcbiAgICAgICAgfSBlbHNlIHtcclxuICAgICAgICAgICAgb3V0ID0gZXZhbCgnKGZ1bmN0aW9uKCl7cmV0dXJuICcgKyBzdHIgKyAnfSgpKTsnKTtcclxuICAgICAgICB9XHJcbiAgICB9IGNhdGNoIChlKSB7XHJcbiAgICAgICAgdGhyb3cgbmV3IEVycm9yKGUubWVzc2FnZSArICdcXHJcXG5cXHJcXG4nICsgc3RyKTtcclxuICAgIH1cclxuICAgIHJldHVybiBvdXQ7XHJcbn1cclxubW9kdWxlLmV4cG9ydHMgPSBjbG9uZUZ1bmN0aW9uOyJdfQ== |
{ | ||
"name": "clone-function", | ||
"version": "1.0.5", | ||
"version": "1.0.6", | ||
"description": "Clones non native JavaScript functions, or references native functions.", | ||
@@ -5,0 +5,0 @@ "main": "./src/clone-function.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
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
197802
3043