remove example and remove cap issues for SyncDish

This commit is contained in:
d98762625 2018-06-18 11:17:54 +01:00
parent c90f30a7a1
commit 471009bc17
4 changed files with 14 additions and 73 deletions

View file

@ -22,15 +22,15 @@ module.exports = function (grunt) {
// Tasks
grunt.registerTask("dev",
"A persistent task which creates a development build whenever source files are modified.",
["clean:dev", "exec:generateConfig", "concurrent:dev"]);
["clean:dev", "exec:generateOpsIndex", "exec:generateConfig", "concurrent:dev"]);
grunt.registerTask("node",
"Compiles CyberChef into a single NodeJS module.",
["clean:node", "clean:config", "exec:generateNodeIndex", "webpack:node", "chmod:build"]);
["clean:node", "clean:config", "exec:generateOpsIndex", "exec:generateNodeIndex", "webpack:node", "chmod:build"]);
grunt.registerTask("test",
"A task which runs all the tests in test/tests.",
["exec:generateNodeIndex", "exec:generateConfig", "exec:tests"]);
["clean", "exec:generateOpsIndex", "exec:generateNodeIndex", "exec:generateConfig", "exec:tests"]);
grunt.registerTask("docs",
"Compiles documentation in the /docs directory.",
@ -38,7 +38,7 @@ module.exports = function (grunt) {
grunt.registerTask("prod",
"Creates a production-ready build. Use the --msg flag to add a compile message.",
["eslint", "clean:prod", "exec:generateConfig", "webpack:web", "inline", "chmod"]);
["eslint", "clean:prod", "exec:generateOpsIndex", "exec:generateConfig", "webpack:web", "inline", "chmod"]);
grunt.registerTask("default",
"Lints the code base",
@ -46,7 +46,7 @@ module.exports = function (grunt) {
grunt.registerTask("inline",
"Compiles a production build of CyberChef into a single, portable web page.",
["exec:generateConfig", "webpack:webInline", "runInliner", "clean:inlineScripts"]);
["exec:generateOpsIndex", "exec:generateConfig", "webpack:webInline", "runInliner", "clean:inlineScripts"]);
grunt.registerTask("runInliner", runInliner);
@ -353,7 +353,7 @@ module.exports = function (grunt) {
watch: {
config: {
files: ["src/core/operations/**/*", "!src/core/operations/index.mjs"],
tasks: ["exec:generateConfig"]
tasks: ["exec:generateNodeIndex", "exec:generateConfig"]
}
},
concurrent: {
@ -382,11 +382,17 @@ module.exports = function (grunt) {
"mkdir -p src/core/config/modules",
"echo 'export default {};\n' > src/core/config/modules/OpModules.mjs",
"echo '[]\n' > src/core/config/OperationConfig.json",
"node --experimental-modules src/core/config/scripts/generateOpsIndex.mjs",
"node --experimental-modules src/core/config/scripts/generateConfig.mjs",
"echo '--- Config scripts finished. ---\n'"
].join(";")
},
generateOpsIndex: {
command: [
"echo '\n--- Regenerating config files. ---'",
"node --experimental-modules src/core/config/scripts/generateOpsIndex.mjs",
"echo '\n--- Ops index generated. ---'",
].join(";")
},
generateNodeIndex: {
command: [
"echo '\n--- Regenerating node index ---'",

View file

@ -1,65 +0,0 @@
/**
* Before using this file, run `npm run build-node`
*
* Run with `node --experimental-modules src/node/example.mjs` from proj root
*/
import chef from "./index";
import {
setUnion,
toBase32,
fromBase32
} from "./index";
import OperationError from "../core/errors/OperationError";
// All ops under the chef object.
let result = chef.toBase32("input");
/**
* Display
*/
// override .inspect so it prints the Dish value
console.log(result); // => NFXHA5LU
// toString override
console.log(String(result)); // => NFXHA5LU
// toValue override
console.log(""+result); // => "NaN"
console.log(3 + chef.fromBase32(chef.toBase32("32"))); // => 35
/**
* Conversion
*/
// synchronous type conversion
console.log(result.get("bytearray")); // => [ 78, 97, 78 ]
console.log(result.get("number")); // => NaN
/**
* Accepts normal input (with args in object) and dish (for chaining)
*/
// default args
console.log(toBase32("something")); // => ONXW2ZLUNBUW4ZY=
// override arg (doesnt have to be them all) - arg names are lenient,
// e.g. would accept 'alphabet', 'Alphabet' & ignores whitespace
console.log(toBase32("something", { alphabet: "A-S" })); // => ONLNB
// Pass result of one op to another
console.log(fromBase32(toBase32("66"))); // => "66"
/**
* Errors
*/
// let all errors (even OperationErrors) bubble up
try {
setUnion("1");
} catch (e) {
console.log(e instanceof OperationError); // => true
}

View file

@ -13,7 +13,7 @@
/**
*
* Print useful stack on error
*/
const wrapRun = (run) => () => {
try {