A package for JavaScript that is essentially just a library of functions I use while scripting. It includes recreations of some Python package functions as well as a few custom functions that might help with development. Most of the functions work for both Node JS and Web JS.
NOTE: None of these ports are official I just ported them over because it made it easier for me. Also sorry if it's a bit messy and some things may be off.
Random:
var {random} = require('./nutfl');- random.randint(min, max);
- random.choice(array);
- random.randopp(chance, min, max);
Asyncio:
var {asyncio} = require('./nutfl');- asyncio.sleep(seconds);
- asyncio.sleepMs(milliseconds);
Datetime:
var {datetime} = require('./nutfl');- datetime.datetime.now(datestring);
Json: (only works on Node JS)
var {json} = require('./nutfl');- json.load(data);
- json.clear(file);
- json.dump(data, file, args)
// these should be separated by a sleep or else they'll break, use await asyncio.sleepMs(5); that should work
json.dump({"a": "b"}, './file.json', {indent: 4});
json.set(".a", "b", './file.json', {indent: 4});
json.set('["a"]', "b", './file.json');
json.clear('./file.json');Html:
var {html} = require('./nutfl');- html.clear();
- html.isFullscreen;
ExtMath:
var {extMath} = require('./nutfl');- extMath.divmod(x, y);
- divmod(x, y);
File & Link:
var {file} = require('./nutfl');
var {link} = require('./nutfl');main file
- file.isJS;
- file.isHTML;
/* index.js */
var {file} = require('./nutfl');
console.log(file.isJS); // true
console.log(file.isHTML); // falsefiles and links
- file.isImage(file, includeGIFS
default false); - file.isGIF(file);
- file.isVideo(file);
- file.isAudio(file);
- file.isType(file, type);
- string.isImage(includeGIFS
default false); - string.isGIF();
- string.isVideo();
- string.isAudio();
- string.isType(type);
<html>
<head>
<script type="text/javascript" src="./nutfl/index.js"></script>
</head>
<body>
<script>
document.write(file.isJS); // false
document.write(file.isHTML); // true
</script>
</body>
</html>Objects:
- object.keys;
- object.values;
- object.length;
- object.stringify(replacer, indent
(optional)); - object.parse(reviver
(optional)); - object.indexOf(name);
- object.fetchKey(index);
- object.fetchValues(index);
let data = {
"a": "b",
"c": ["d", "e"]
};
console.log(data.length); // 2
console.log(data.keys); // ["a", "c"]
console.log(data.values); // ["b", ["d", "e"]]
console.log(data.indexOf("c")); // 1
console.log(data.fetchKey(1)); // "c"
console.log(data.fetchValues(1)); // ["d", "e"]Array:
- array.randomChoice();
- array.endsWithC(char);
- array.startsWithC(char);
- array.equalFor(array);
- array.prune(amount, direction);
- array.remove(index);
- array.flip(index1, index2);
- array.includesFor(array);
Strings:
- string.replaceFor(array, replaceWith);
- string.endsWithC(char);
- string.startsWithC(char);
- string.get(index, type
word or letter); - string.includesFor(array);
- string.startsWithFor(array);
- string.endsWithFor(array);
- string.isImage(includeGIFS
default false); - string.isGIF();
- string.isVideo();
- string.isAudio();
- string.isType(type);
Node JS:
var {random, asyncio} = require("./nutfl");Web JS / HTML:
<head>
<script type="text/javascript" src="./nutfl/index.js"></script>
</head>