unlimited-curry
Advanced tools
Comparing version 1.3.2 to 1.3.3
'use strict'; | ||
var returnFromPromise = 1; | ||
var returnFromCallback = 0; | ||
var getFrom = function getFrom(from, dataArgument) { | ||
var workData = dataArgument; | ||
var returnArrayChunks = workData.returnArrayChunks.slice(from); | ||
var returnArray = []; | ||
returnArrayChunks.forEach(function (chunkData) { | ||
return chunkData.forEach(function (pieceData) { | ||
return returnArray.push(pieceData); | ||
}); | ||
}); | ||
var data = { returnArray: returnArray, returnArrayChunks: returnArrayChunks }; | ||
var returnObject = { data: data, getFrom: getFrom }; | ||
var command = { | ||
has: function has(command) { | ||
return returnObject.data.returnArrayChunks.some(function (argumentArray) { | ||
return argumentArray[0] === command; | ||
}); | ||
}, | ||
get: function get(command) { | ||
return returnObject.data.returnArrayChunks.filter(function (argumentArray) { | ||
return argumentArray[0] === command; | ||
}); | ||
}, | ||
getArguments: function getArguments(command, commands) { | ||
return this.get(command, commands).map(function (command) { | ||
return command.slice(1); | ||
}); | ||
} | ||
}; | ||
returnObject.command = command; | ||
return returnObject; | ||
}; | ||
var safetyExecutor = function safetyExecutor(data, callback) { | ||
var timeoutSate = null; | ||
if (callback && typeof callback === 'function') { | ||
timeoutSate = setTimeout(callback, 0, 2, data); | ||
} | ||
return timeoutSate; | ||
}; | ||
var UnlimitedCurry = function UnlimitedCurry(callback) { | ||
var timeoutSate = null; | ||
var level = 0; | ||
var returnArray = []; | ||
var returnArrayChunks = []; | ||
var state = { | ||
timeoutSate: timeoutSate, | ||
level: level, | ||
returnArray: returnArray, | ||
returnArrayChunks: returnArrayChunks, | ||
resetMe: false, | ||
reset: function reset() { | ||
if (this.resetMe) { | ||
this.level = 0; | ||
this.returnArray = []; | ||
this.returnArrayChunks = []; | ||
this.resetMe = false; | ||
} | ||
}, | ||
clone: function clone() { | ||
return { | ||
timeoutSate: timeoutSate, | ||
level: this.level, | ||
returnArray: this.returnArray.slice(0), | ||
returnArrayChunks: this.returnArrayChunks.slice(0), | ||
resetMe: this.resetMe, | ||
reset: this.reset, | ||
clone: this.clone, | ||
getData: this.getData | ||
}; | ||
}, | ||
getData: function getData() { | ||
var me = this; | ||
return getFrom(0, { returnArrayChunks: me.returnArrayChunks }); | ||
} | ||
}; | ||
var caller = function caller() { | ||
// parameters | ||
if (!caller.called) { | ||
caller.called = true; | ||
return caller; | ||
} | ||
state.reset(); | ||
state.level++; | ||
var callerArguments = Array.from(arguments); | ||
if (callerArguments.length) { | ||
state.returnArrayChunks.push(callerArguments); | ||
} | ||
var data = caller.data = getFrom(0, { returnArrayChunks: state.returnArrayChunks }); | ||
caller.p = function () { | ||
return new Promise(function (resolve, reject) { | ||
clearTimeout(state.timeoutSate); | ||
var conedState = state.clone(); | ||
var ret = false; | ||
var data = conedState.getData(); | ||
if (typeof callback === 'function') { | ||
ret = callback(returnFromPromise, data); | ||
} else { | ||
ret = data; | ||
} | ||
state.resetMe = true; | ||
return resolve(ret); | ||
}); | ||
}; | ||
/* istanbul ignore else */ | ||
if (!arguments.length) { | ||
/* istanbul ignore else */ | ||
if (callback) { | ||
/* istanbul ignore else */ | ||
if (typeof callback === 'function') { | ||
clearTimeout(state.timeoutSate); | ||
state.resetMe = true; | ||
return callback(returnFromCallback, data); | ||
} | ||
} | ||
/* istanbul ignore else */ | ||
if (!callback) { | ||
return data; | ||
} | ||
} | ||
/* istanbul ignore else */ | ||
if (arguments.length) { | ||
/* istanbul ignore else */ | ||
if (state.timeoutSate) { | ||
clearTimeout(state.timeoutSate); | ||
} | ||
state.timeoutSate = safetyExecutor(data, callback); | ||
} | ||
state.level++; | ||
return caller; | ||
}; | ||
return caller(state.returnArray); | ||
}; | ||
module.exports = exports = UnlimitedCurry; | ||
var unlimitedCurryFactory = require('./unlimited-curry-factory'); | ||
var unlimitedCurryFactoryInitiator = unlimitedCurryFactory(false, true)(function (error, parameters) { | ||
return unlimitedCurryFactory(parameters); | ||
}); | ||
module.exports = exports = unlimitedCurryFactoryInitiator(); | ||
exports.extra = unlimitedCurryFactoryInitiator; |
{ | ||
"name": "unlimited-curry", | ||
"version": "1.3.2", | ||
"version": "1.3.3", | ||
"description": "Unlimited curry", | ||
@@ -84,6 +84,6 @@ "main": "dist/src/index.js", | ||
"/build/", | ||
"/tmp/" | ||
"/tmp/", | ||
"/src/index.js" | ||
] | ||
}, | ||
"gitHead": "75b905e4c4e804f5e5a58e41b560b076e10d7a34" | ||
} | ||
} |
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
16002
9
236
1