async-invoker 1.1.2 → 2.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,30 @@
1
+ Note: This is just a template, so feel free to use/remove the unnecessary things
2
+
3
+ ### Description
4
+ - Type: Bug | Enhancement | Question
5
+ - Related Issue: `#abc`
6
+
7
+ ---------------------------------------------------------------
8
+ ## Bug
9
+ **Expected Behavior**
10
+
11
+ **Actual Behavior**
12
+
13
+ **Steps to Reproduce**
14
+
15
+ ----------------------------------------------------------------
16
+ ## Enhancement
17
+
18
+ **Reason to enhance/problem with existing solution**
19
+
20
+ **Suggested enhancement**
21
+
22
+ **Pros**
23
+
24
+ **Cons**
25
+
26
+ -----------------------------------------------------------------
27
+
28
+ ## Question
29
+
30
+ **How to?**
@@ -0,0 +1,3 @@
1
+ [Finishes #ID](https://www.pivotaltracker.com/story/show/ID)
2
+
3
+ - [ ] App levantada, probada y con los tests corridos! [👌](https://c.tenor.com/joILBoleQeoAAAAC/ricky-fort.gif)
@@ -0,0 +1,14 @@
1
+ name: Trufflehog Scan
2
+
3
+ on:
4
+ pull_request:
5
+ branches:
6
+ - main
7
+ - master
8
+
9
+ jobs:
10
+ trufflehog-scan:
11
+ uses: Parsimotion/public-workflows/.github/workflows/trufflehog-scan.yml@main
12
+ with:
13
+ pr-number: ${{ github.event.pull_request.number }}
14
+ base-commit: ${{ github.event.pull_request.base.sha }}
@@ -0,0 +1,5 @@
1
+ {
2
+ "presets": [
3
+ ["@babel/preset-env"]
4
+ ]
5
+ }
@@ -1,81 +1,69 @@
1
- (function() {
2
- var AsyncInvoker, Promise, _, eval_,
3
- bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
4
- slice = [].slice;
1
+ "use strict";
5
2
 
6
- Promise = require("bluebird");
7
-
8
- eval_ = require("eval");
9
-
10
- _ = require("lodash");
11
-
12
- module.exports = AsyncInvoker = (function() {
13
- function AsyncInvoker(code, options, globals) {
14
- this.options = options != null ? options : {};
15
- if (globals == null) {
16
- globals = {};
3
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
+ function _readOnlyError(r) { throw new TypeError('"' + r + '" is read-only'); }
5
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
6
+ function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
7
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
8
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
9
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
10
+ var Promise = require("bluebird");
11
+ var eval_ = require("eval");
12
+ var _ = require("lodash");
13
+ var AsyncInvoker = /*#__PURE__*/function () {
14
+ function AsyncInvoker(code) {
15
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
16
+ var globals = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
17
+ _classCallCheck(this, AsyncInvoker);
18
+ this.options = options;
19
+ _.defaults(this.options, {
20
+ logErrors: true
21
+ });
22
+ code = "module.exports = ".concat(code);
23
+ this._invoke = this._doSomething(function () {
24
+ return eval_(code, globals);
25
+ });
26
+ this._assertIsFunction(this._invoke);
27
+ }
28
+ return _createClass(AsyncInvoker, [{
29
+ key: "invoke",
30
+ value: function invoke() {
31
+ var _this = this;
32
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
33
+ args[_key] = arguments[_key];
17
34
  }
18
- this._assertIsFunction = bind(this._assertIsFunction, this);
19
- this._doSomething = bind(this._doSomething, this);
20
- this.invoke = bind(this.invoke, this);
21
- _.defaults(this.options, {
22
- logErrors: true
35
+ var invoke = function invoke(functionArgs) {
36
+ return _this._doSomething(function () {
37
+ return _this._invoke.apply(null, functionArgs);
38
+ });
39
+ };
40
+ var tryLog = function tryLog(e) {
41
+ if (_this.options.logErrors) console.log(e);
42
+ };
43
+ return new Promise(function (resolve, reject) {
44
+ try {
45
+ var output = invoke(args.concat(resolve));
46
+ if (!_.isUndefined(output)) {
47
+ resolve(output);
48
+ }
49
+ } catch (e) {
50
+ tryLog(e);
51
+ reject(e);
52
+ }
23
53
  });
24
- code = "module.exports = " + code;
25
- this._invoke = this._doSomething(((function(_this) {
26
- return function() {
27
- return eval_(code, globals);
28
- };
29
- })(this)));
30
- this._assertIsFunction(this._invoke);
31
54
  }
32
-
33
- AsyncInvoker.prototype.invoke = function() {
34
- var args, invoke, tryLog;
35
- args = 1 <= arguments.length ? slice.call(arguments, 0) : [];
36
- invoke = (function(_this) {
37
- return function(functionArgs) {
38
- return _this._doSomething((function() {
39
- return _this._invoke.apply(null, functionArgs);
40
- }));
41
- };
42
- })(this);
43
- tryLog = (function(_this) {
44
- return function(e) {
45
- if (_this.options.logErrors) {
46
- return console.log(e);
47
- }
48
- };
49
- })(this);
50
- return new Promise((function(_this) {
51
- return function(resolve, reject) {
52
- var e, error, output;
53
- try {
54
- output = invoke(args.concat(resolve));
55
- if (!_.isUndefined(output)) {
56
- return resolve(output);
57
- }
58
- } catch (error) {
59
- e = error;
60
- tryLog(e);
61
- return reject(e);
62
- }
63
- };
64
- })(this));
65
- };
66
-
67
- AsyncInvoker.prototype._doSomething = function(doSomething) {
55
+ }, {
56
+ key: "_doSomething",
57
+ value: function _doSomething(doSomething) {
68
58
  return doSomething();
69
- };
70
-
71
- AsyncInvoker.prototype._assertIsFunction = function(func) {
59
+ }
60
+ }, {
61
+ key: "_assertIsFunction",
62
+ value: function _assertIsFunction(func) {
72
63
  if (!_.isFunction(func)) {
73
64
  throw new Error("The function is not a function");
74
65
  }
75
- };
76
-
77
- return AsyncInvoker;
78
-
79
- })();
80
-
81
- }).call(this);
66
+ }
67
+ }]);
68
+ }();
69
+ module.exports = AsyncInvoker;
package/lib/index.js CHANGED
@@ -1,4 +1,3 @@
1
- (function() {
2
- module.exports = require("./async.invoker");
1
+ "use strict";
3
2
 
4
- }).call(this);
3
+ module.exports = require("./async.invoker");
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "async-invoker",
3
- "version": "1.1.2",
3
+ "version": "2.0.0-beta.1",
4
4
  "description": "Create a runner of code asynchronous",
5
5
  "main": "index.js",
6
6
  "scripts": {
7
- "test": "grunt test",
8
- "prepublish": "grunt build"
7
+ "test": "mocha --require @babel/register --reporter spec 'src/**/*.spec.js'",
8
+ "build": "rm -rf lib && babel src --out-dir lib --ignore 'src/**/*.spec.js'",
9
+ "prepublish": "npm run build"
9
10
  },
10
11
  "repository": {
11
12
  "type": "git",
@@ -13,15 +14,14 @@
13
14
  },
14
15
  "dependencies": {
15
16
  "bluebird": "3.4.6",
16
- "eval": "0.1.4",
17
- "lodash": "4.17.15"
17
+ "eval": "0.1.6",
18
+ "lodash": "^4.18.1"
18
19
  },
19
20
  "devDependencies": {
20
- "grunt": "1.0.1",
21
- "grunt-bump": "0.8.0",
22
- "grunt-contrib-clean": "1.0.0",
23
- "grunt-contrib-coffee": "1.0.0",
24
- "grunt-mocha-test": "0.12.7",
21
+ "@babel/cli": "^7.24.0",
22
+ "@babel/core": "^7.24.0",
23
+ "@babel/preset-env": "^7.24.0",
24
+ "@babel/register": "^7.24.0",
25
25
  "mocha": "3.0.2",
26
26
  "should": "11.1.0"
27
27
  },