1.4.0
Random Stuff Update 🐢 🍲
Stews 1.4.0
This update adds a few cool things that I thought were big enough to make a full update for
Stew/Soup.random
Random is now built inside stews and soups so now you can do things like this:
stew.random.choice();
stew.random.index();
soup.random.choice();
soup.random.index();
JSON Dumping
Dump lets you put your stew or soup into a JSON file
stew.dump("./file.json"); // without indent
stew.dump("./file.json", null, 4); // with indent
soup.dump("./file.json"); // without indent
soup.dump("./file.json", null, 4); // with indent
Symbol Primitive and Iterator
Added symbol stuff to make for of and other stuff work
Primitive
let list = new Stew( [1, 2, 3, 4] );
let pair = new Stew( {"key0": "value0", "key1": "value1"} );
console.log(`${list}`); // "1,2,3,4"
console.log(`${pair}`); // "key0,value0,key1,value1"
Iterator
let list = new Stew( ["a", "b", "c", "d"] );
let pair = new Stew( {"key0": "value0", "key1": "value1"} );
for ( [value, index] of list ) {
console.log(value, index);
}
for ( [key, value, index] of pair) {
console.log(key, value, index);
}
Properties
Lets you get the properties of a stew/soup including the names, descriptors, and methods
object.properties.names; // returns an array of the property names including functions
object.props.descriptors; // returns an object with all of the data for the stuff including functions
object.props.methods; // returns an object with all of the functions