jsbakery
v0.0.3
Published
Bake up your javascript using the new bake module
Readme
jsbake
jsbake is a Node.js module that provides various utility classes and functions for file operations, color manipulation, tuples, dice rolling, and converting between RGB and hexadecimal color representations.
Installation
You can install jsbake via npm:
npm install jsbakeUsage
const jsbake = require('jsbake');
const Mix = new jsbake
Mix
// FileOperations
// Create a new folder and file
const folder = new Mix.FileOperations.Folder('example_folder');
folder.Create();
const file = new Mix.FileOperations.File('example_folder/example.txt', 'Hello, world!');
file.Create();
// ColorPalette
// Generate a color palette in Advanced mode
const colorPalette = new Mix.ColorPalette('Advanced');
console.log(colorPalette.Colors.Hex);
// Tuple
// Create an immutable tuple
const Tuple = new Mix.Tuple;
const myTuple = new Tuple(1, 2, 3);
// Dice
// Roll a six-sided die three times
const dice = new Mix.Dice();
const rolls = dice.Roll(3, 6);
console.log(rolls);
// RGB2Hex and Hex2RGB
// Convert RGB to hexadecimal
const RGB2Hex = new Mix.RGB2Hex;
const Hex2RGB = new Mix.Hex2RGB;
const hexValue = RGB2Hex(255, 0, 0);
console.log(hexValue); // Output: #ff0000
// Convert hexadecimal to RGB
const rgbValues = Hex2RGB('#00ff00');
console.log(rgbValues); // Output: [0, 255, 0]
// Bake
// Import specific modules
utilities.ImportModule(["FileOperations", "ColorPalette", "Tuple", "Dice", "RGB2Hex", "Hex2RGB"]);
// Use imported modules
// (See examples above for specific module usage)Features Overview
FileOperations
Folder Class:
constructor(path)Create()Write(file)Contents()Delete()
File Class:
constructor(path, content)Create()Write(data)Read()SyncPush()SyncPull()Delete()
ImportFolder Class:
- Inherits all features from the Folder class.
- Automatically imports files from a specified folder.
ImportFile Class:
- Inherits all features from the File class.
- Automatically imports content from a specified file.
FilePerms Function:
FilePerms(path, perms)
ColorPalette
ColorPalette Class:
constructor(mode)
Tuple
Tuple Class:
constructor(...values)
Dice
Dice Class:
constructor()Roll(Dice, Sides)
RGB2Hex and Hex2RGB
RGB2Hex Function:
RGB2Hex(R, G, B)
Hex2RGB Function:
Hex2RGB(Hex)
Location Class
new Location(latitude, longitude);currentLocation.calculateDistance(destination);
Bake
Bake Class:
constructor()ImportModule(modules, imports)
