Explorar o código

Added 'Sleep' operation.

n1474335 %!s(int64=7) %!d(string=hai) anos
pai
achega
f528930ad2

+ 8 - 2
Gruntfile.js

@@ -186,7 +186,10 @@ module.exports = function (grunt) {
             options: webpackConfig,
             options: webpackConfig,
             metaConf: {
             metaConf: {
                 target: "node",
                 target: "node",
-                entry: "./src/core/config/OperationConfig.js",
+                entry: [
+                    "babel-polyfill",
+                    "./src/core/config/OperationConfig.js"
+                ],
                 output: {
                 output: {
                     filename: "MetaConfig.js",
                     filename: "MetaConfig.js",
                     path: __dirname + "/src/core/config/",
                     path: __dirname + "/src/core/config/",
@@ -198,7 +201,10 @@ module.exports = function (grunt) {
             },
             },
             metaConfDev: {
             metaConfDev: {
                 target: "node",
                 target: "node",
-                entry: "./src/core/config/OperationConfig.js",
+                entry: [
+                    "babel-polyfill",
+                    "./src/core/config/OperationConfig.js"
+                ],
                 output: {
                 output: {
                     filename: "MetaConfig.js",
                     filename: "MetaConfig.js",
                     path: __dirname + "/src/core/config/",
                     path: __dirname + "/src/core/config/",

+ 2 - 0
src/core/config/Categories.js

@@ -201,6 +201,7 @@ const Categories = [
             "Escape string",
             "Escape string",
             "Unescape string",
             "Unescape string",
             "Pseudo-Random Number Generator",
             "Pseudo-Random Number Generator",
+            "Sleep",
         ]
         ]
     },
     },
     {
     {
@@ -213,6 +214,7 @@ const Categories = [
             "Windows Filetime to UNIX Timestamp",
             "Windows Filetime to UNIX Timestamp",
             "UNIX Timestamp to Windows Filetime",
             "UNIX Timestamp to Windows Filetime",
             "Extract dates",
             "Extract dates",
+            "Sleep",
         ]
         ]
     },
     },
     {
     {

+ 13 - 0
src/core/config/OperationConfig.js

@@ -2441,6 +2441,19 @@ const OperationConfig = {
             }
             }
         ]
         ]
     },
     },
+    "Sleep": {
+        module: "Default",
+        description: "Sleep causes the recipe to wait for a specified number of milliseconds before continuing execution.",
+        inputType: "ArrayBuffer",
+        outputType: "ArrayBuffer",
+        args: [
+            {
+                name: "Time (ms)",
+                type: "number",
+                value: 1000
+            }
+        ]
+    },
     "Windows Filetime to UNIX Timestamp": {
     "Windows Filetime to UNIX Timestamp": {
         module: "JSBN",
         module: "JSBN",
         description: "Converts a Windows Filetime value to a UNIX timestamp.<br><br>A Windows Filetime is a 64-bit value representing the number of 100-nanosecond intervals since January 1, 1601 UTC.<br><br>A UNIX timestamp is a 32-bit value representing the number of seconds since January 1, 1970 UTC (the UNIX epoch).<br><br>This operation also supports UNIX timestamps in milliseconds, microseconds and nanoseconds.",
         description: "Converts a Windows Filetime value to a UNIX timestamp.<br><br>A Windows Filetime is a 64-bit value representing the number of 100-nanosecond intervals since January 1, 1601 UTC.<br><br>A UNIX timestamp is a 32-bit value representing the number of seconds since January 1, 1970 UTC (the UNIX epoch).<br><br>This operation also supports UNIX timestamps in milliseconds, microseconds and nanoseconds.",

+ 1 - 0
src/core/config/modules/Default.js

@@ -130,6 +130,7 @@ OpModules.Default = {
     "Translate DateTime Format": DateTime.runTranslateFormat,
     "Translate DateTime Format": DateTime.runTranslateFormat,
     "From UNIX Timestamp":  DateTime.runFromUnixTimestamp,
     "From UNIX Timestamp":  DateTime.runFromUnixTimestamp,
     "To UNIX Timestamp":    DateTime.runToUnixTimestamp,
     "To UNIX Timestamp":    DateTime.runToUnixTimestamp,
+    "Sleep":                DateTime.runSleep,
     "Microsoft Script Decoder": MS.runDecodeScript,
     "Microsoft Script Decoder": MS.runDecodeScript,
     "Entropy":              Entropy.runEntropy,
     "Entropy":              Entropy.runEntropy,
     "Frequency distribution": Entropy.runFreqDistrib,
     "Frequency distribution": Entropy.runFreqDistrib,

+ 14 - 0
src/core/operations/DateTime.js

@@ -189,6 +189,20 @@ const DateTime = {
     },
     },
 
 
 
 
+    /**
+     * Sleep operation.
+     *
+     * @param {ArrayBuffer} input
+     * @param {Object[]} args
+     * @returns {ArrayBuffer}
+     */
+    runSleep: async function(input, args) {
+        const ms = args[0];
+        await new Promise(r => setTimeout(r, ms));
+        return input;
+    },
+
+
     /**
     /**
      * @constant
      * @constant
      */
      */