diff options
| author | Danijel Andjelkovic <adanijel99@gmail.com> | 2022-03-01 21:54:41 +0100 | 
|---|---|---|
| committer | Danijel Andjelkovic <adanijel99@gmail.com> | 2022-03-01 21:54:41 +0100 | 
| commit | 6c8128f9fd5a5d0be115806c35a21b3d683df8d6 (patch) | |
| tree | f46c2f6b3b9b294ff32bd75c08ccdc9e7a8cc4ef /sandbox/testAppNevena/Front/node_modules/run-async | |
| parent | 2400b84e95913665da6279114168148444b8f9ab (diff) | |
| parent | 7d3640f824f46490b47bd95f1c5a16644f712068 (diff) | |
Merge branch 'dev' of http://gitlab.pmf.kg.ac.rs/igrannonica/neuronstellar into logo
Diffstat (limited to 'sandbox/testAppNevena/Front/node_modules/run-async')
4 files changed, 225 insertions, 0 deletions
| diff --git a/sandbox/testAppNevena/Front/node_modules/run-async/LICENSE b/sandbox/testAppNevena/Front/node_modules/run-async/LICENSE new file mode 100644 index 00000000..e895e99b --- /dev/null +++ b/sandbox/testAppNevena/Front/node_modules/run-async/LICENSE @@ -0,0 +1,21 @@ +The MIT License (MIT) + +Copyright (c) 2014 Simon Boudrias + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/sandbox/testAppNevena/Front/node_modules/run-async/README.md b/sandbox/testAppNevena/Front/node_modules/run-async/README.md new file mode 100644 index 00000000..8eb62c24 --- /dev/null +++ b/sandbox/testAppNevena/Front/node_modules/run-async/README.md @@ -0,0 +1,79 @@ +Run Async +========= + +[](http://badge.fury.io/js/run-async) [](http://travis-ci.org/SBoudrias/run-async) [](https://david-dm.org/SBoudrias/run-async) + +Utility method to run a function either synchronously or asynchronously using a series of common patterns. This is useful for library author accepting sync or async functions as parameter. `runAsync` will always run them as an async method, and normalize the multiple signature. + +Installation +========= + +```bash +npm install --save run-async +``` + +Usage +========= + +Here's a simple example print the function results and three options a user can provide a function. + +```js +var runAsync = require('run-async'); + +var printAfter = function (func) { +  var cb = function (err, returnValue) { +    console.log(returnValue); +  }; +  runAsync(func, cb)(/* arguments for func */); +}; +``` + +#### Using `this.async` +```js +printAfter(function () { +  var done = this.async(); + +  setTimeout(function () { +    done(null, 'done running with callback'); +  }, 10); +}); +``` + +#### Returning a promise +```js +printAfter(function () { +  return new Promise(function (resolve, reject) { +    resolve('done running with promises'); +  }); +}); +``` + +#### Synchronous function +```js +printAfter(function () { +  return 'done running sync function'; +}); +``` + +### runAsync.cb + +`runAsync.cb` supports all the function types that `runAsync` does and additionally a traditional **callback as the last argument** signature: + +```js +var runAsync = require('run-async'); + +// IMPORTANT: The wrapped function must have a fixed number of parameters. +runAsync.cb(function(a, b, cb) { +  cb(null, a + b); +}, function(err, result) { +  console.log(result) +})(1, 2) +``` + +If your version of node support Promises natively (node >= 0.12), `runAsync` will return a promise. Example: `runAsync(func)(arg1, arg2).then(cb)` + +Licence +======== + +Copyright (c) 2014 Simon Boudrias (twitter: @vaxilart)   +Licensed under the MIT license. diff --git a/sandbox/testAppNevena/Front/node_modules/run-async/index.js b/sandbox/testAppNevena/Front/node_modules/run-async/index.js new file mode 100644 index 00000000..c7a2e65d --- /dev/null +++ b/sandbox/testAppNevena/Front/node_modules/run-async/index.js @@ -0,0 +1,98 @@ +'use strict'; + +function isPromise(obj) { +  return !!obj && (typeof obj === 'object' || typeof obj === 'function') && typeof obj.then === 'function'; +} + +/** + * Return a function that will run a function asynchronously or synchronously + * + * example: + * runAsync(wrappedFunction, callback)(...args); + * + * @param   {Function} func  Function to run + * @param   {Function} cb    Callback function passed the `func` returned value + * @return  {Function(arguments)} Arguments to pass to `func`. This function will in turn + *                                return a Promise (Node >= 0.12) or call the callbacks. + */ + +var runAsync = module.exports = function (func, cb) { +  cb = cb || function () {}; + +  return function () { + +    var args = arguments; + +    var promise = new Promise(function (resolve, reject) { +      var resolved = false; +      const wrappedResolve = function (value) { +        if (resolved) { +          console.warn('Run-async promise already resolved.') +        } +        resolved = true; +        resolve(value); +      } + +      var rejected = false; +      const wrappedReject = function (value) { +        if (rejected) { +          console.warn('Run-async promise already rejected.') +        } +        rejected = true; +        reject(value); +      } + +      var usingCallback = false; +      var callbackConflict = false; +      var contextEnded = false; + +      var answer = func.apply({ +        async: function () { +          if (contextEnded) { +            console.warn('Run-async async() called outside a valid run-async context, callback will be ignored.'); +            return function() {}; +          } +          if (callbackConflict) { +            console.warn('Run-async wrapped function (async) returned a promise.\nCalls to async() callback can have unexpected results.'); +          } +          usingCallback = true; +          return function (err, value) { +            if (err) { +              wrappedReject(err); +            } else { +              wrappedResolve(value); +            } +          }; +        } +      }, Array.prototype.slice.call(args)); + +      if (usingCallback) { +        if (isPromise(answer)) { +          console.warn('Run-async wrapped function (sync) returned a promise but async() callback must be executed to resolve.'); +        } +      } else { +        if (isPromise(answer)) { +          callbackConflict = true; +          answer.then(wrappedResolve, wrappedReject); +        } else { +          wrappedResolve(answer); +        } +      } +      contextEnded = true; +    }); + +    promise.then(cb.bind(null, null), cb); + +    return promise; +  } +}; + +runAsync.cb = function (func, cb) { +  return runAsync(function () { +    var args = Array.prototype.slice.call(arguments); +    if (args.length === func.length - 1) { +      args.push(this.async()); +    } +    return func.apply(this, args); +  }, cb); +}; diff --git a/sandbox/testAppNevena/Front/node_modules/run-async/package.json b/sandbox/testAppNevena/Front/node_modules/run-async/package.json new file mode 100644 index 00000000..b923265d --- /dev/null +++ b/sandbox/testAppNevena/Front/node_modules/run-async/package.json @@ -0,0 +1,27 @@ +{ +  "name": "run-async", +  "version": "2.4.1", +  "description": "Utility method to run function either synchronously or asynchronously using the common `this.async()` style.", +  "main": "index.js", +  "scripts": { +    "test": "mocha -R spec" +  }, +  "engines": { +    "node": ">=0.12.0" +  }, +  "repository": "SBoudrias/run-async", +  "keywords": [ +    "flow", +    "flow-control", +    "async" +  ], +  "files": [ +    "index.js" +  ], +  "author": "Simon Boudrias <admin@simonboudrias.com>", +  "license": "MIT", +  "dependencies": {}, +  "devDependencies": { +    "mocha": "^7.1.0" +  } +} | 
