mirror of
https://github.com/gchq/CyberChef
synced 2025-12-26 13:13:33 +00:00
WIP: generate top level node exports - manually mock lib files
This commit is contained in:
@@ -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};
|
||||
Reference in New Issue
Block a user