mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-21 15:26:16 -04:00
WIP: generate top level node exports - manually mock lib files
This commit is contained in:
parent
0977e82170
commit
0a0240e520
5 changed files with 125 additions and 38 deletions
|
@ -163,9 +163,14 @@ export function help(operations, searchTerm) {
|
|||
* @returns {String} decapitalised
|
||||
*/
|
||||
export function decapitalise(name) {
|
||||
// Don't decapitalise names that are purely uppercase
|
||||
if (/^[A-Z0-9]+$/g.test(name)) {
|
||||
// Don't decapitalise names that start with 2+ caps
|
||||
if (/^[A-Z0-9]{2,}/g.test(name)) {
|
||||
return name;
|
||||
}
|
||||
// reserved. Don't change for now.
|
||||
if (name === "Return") {
|
||||
return name;
|
||||
}
|
||||
|
||||
return `${name.charAt(0).toLowerCase()}${name.substr(1)}`;
|
||||
}
|
||||
|
|
|
@ -1,35 +0,0 @@
|
|||
/**
|
||||
* Node view for CyberChef.
|
||||
*
|
||||
* @author n1474335 [n1474335@gmail.com]
|
||||
* @copyright Crown Copyright 2018
|
||||
* @license Apache-2.0
|
||||
*/
|
||||
import "babel-polyfill";
|
||||
|
||||
import {wrap, help, decapitalise, translateTo} from "./apiUtils";
|
||||
import * as operations from "../core/operations/index";
|
||||
|
||||
// Define global environment functions
|
||||
global.ENVIRONMENT_IS_WORKER = function() {
|
||||
return typeof importScripts === "function";
|
||||
};
|
||||
global.ENVIRONMENT_IS_NODE = function() {
|
||||
return typeof process === "object" && typeof require === "function";
|
||||
};
|
||||
global.ENVIRONMENT_IS_WEB = function() {
|
||||
return typeof window === "object";
|
||||
};
|
||||
|
||||
|
||||
const chef = {};
|
||||
|
||||
// Add in wrapped operations with camelCase names
|
||||
Object.keys(operations).forEach(op =>
|
||||
chef[decapitalise(op)] = wrap(operations[op]));
|
||||
|
||||
chef.help = help.bind(null, operations);
|
||||
chef.translateTo = translateTo;
|
||||
|
||||
export default chef;
|
||||
export {chef};
|
Loading…
Add table
Add a link
Reference in a new issue