First Commit of new way of building the Platform

This commit is contained in:
Luis Fernando Molina committed 2020-01-28 17:27:23 +01:00
1 parent e48cf0dae5
commit 40e60b42cc
4616 files changed
+713402

No files matched your search

+37
View File
@@ -0,0 +1,37 @@
'use strict';
/**
* Wrap callbacks to prevent double execution.
*
* @param {Function} fn Function that should only be called once.
* @returns {Function} A wrapped callback which prevents execution.
* @api public
*/
module.exports = function one(fn) {
var called = 0
, value;
/**
* The function that prevents double execution.
*
* @api private
*/
function onetime() {
if (called) return value;
called = 1;
value = fn.apply(this, arguments);
fn = null;
return value;
}
//
// To make debugging more easy we want to use the name of the supplied
// function. So when you look at the functions that are assigned to event
// listeners you don't see a load of `onetime` functions but actually the
// names of the functions that this module will call.
//
onetime.displayName = fn.displayName || fn.name || onetime.displayName || onetime.name;
return onetime;
};
+68
View File
@@ -0,0 +1,68 @@
{
"_args": [
[
"one-time@0.0.4",
"C:\\Users\\Luis\\source\\repos\\AAMasters\\TaskServer"
]
],
"_from": "one-time@0.0.4",
"_id": "one-time@0.0.4",
"_inBundle": false,
"_integrity": "sha1-+M33eISCb+Tf+T46nMN7HkSAdC4=",
"_location": "/one-time",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "one-time@0.0.4",
"name": "one-time",
"escapedName": "one-time",
"rawSpec": "0.0.4",
"saveSpec": null,
"fetchSpec": "0.0.4"
},
"_requiredBy": [
"/winston"
],
"_resolved": "https://registry.npmjs.org/one-time/-/one-time-0.0.4.tgz",
"_spec": "0.0.4",
"_where": "C:\\Users\\Luis\\source\\repos\\AAMasters\\TaskServer",
"author": {
"name": "Arnout Kazemier"
},
"bugs": {
"url": "https://github.com/unshiftio/one-time/issues"
},
"description": "Run the supplied function exactly one time (once)",
"devDependencies": {
"assume": "1.2.x",
"istanbul": "0.3.x",
"mocha": "2.2.x",
"pre-commit": "1.0.x"
},
"homepage": "https://github.com/unshiftio/one-time#readme",
"keywords": [
"once",
"function",
"single",
"one",
"one-time",
"execution",
"nope"
],
"license": "MIT",
"main": "index.js",
"name": "one-time",
"repository": {
"type": "git",
"url": "git+https://github.com/unshiftio/one-time.git"
},
"scripts": {
"100%": "istanbul check-coverage --statements 100 --functions 100 --lines 100 --branches 100",
"coverage": "istanbul cover ./node_modules/.bin/_mocha -- test.js",
"test": "mocha test.js",
"test-travis": "istanbul cover node_modules/.bin/_mocha --report lcovonly -- test.js",
"watch": "mocha --watch test.js"
},
"version": "0.0.4"
}
+45
View File
@@ -0,0 +1,45 @@
describe('one-time', function () {
'use strict';
var assume = require('assume')
, one = require('./');
it('is exported as a function', function () {
assume(one).is.a('function');
});
it('only calls the supplied function once', function (next) {
next = one(next);
next();
next();
next();
next();
});
it('returns the same value as the called function every single time', function () {
var foo = one(function () {
return 'bar';
});
assume(foo()).equals('bar');
assume(foo()).equals('bar');
assume(foo()).equals('bar');
assume(foo()).equals('bar');
assume(foo()).equals('bar');
assume(foo()).equals('bar');
assume(foo()).equals('bar');
assume(foo()).equals('bar');
assume(foo()).equals('bar');
assume(foo()).equals('bar');
assume(foo()).equals('bar');
});
it('the returned function uses the same displayName as the given fn', function () {
var foo = one(function banana() {
return 'bar';
});
assume(foo.displayName).equals('banana');
});
});