0.1.2 • Published 4 years ago
neamonjs v0.1.2
NeamonJS
- A lightweight and easy to use language based and written on javascript.
- Allows you to reload modules in real time.
- If you need help write to me at Telegram @nelonn
- If you encounter any of those fell free to open an issue in our github repository.
Download & Update
You can download it from npm:
npm i neamonjsYou can update to a newer version to receive updates using npm.
npm update neamonjsChangelog
...
Setting Up
The first option (allows you to package the application)
index.js:
const neamon = require('neamonjs');
neamon(__dirname, 'script.njs');The second option (no .js files)
package.json:
...
"scripts": {
"start": "neamon script.njs"
},
...Example
Example modules:
hello_world.njs:
exports.sayHello = () => {
console.log('Hello World!');
};script.njs:
const hello_world = get('./hello_world.njs');
hello_world.sayHello();Differences from JS
get
Warning, get ≠ require!
Use get(filename) only for .njs files
and use require(filename) for everyone else
Exports
exports = 'simple_string';This will return an error, you need to do this:
exports.string = 'simple_string';Map
Now Map has a find method:
const testMap = new Map();
testMap.set('some_key', { string: 'some string', number: 10 });
console.log(testMap.find(e => e.number === 10));- Output:
{ string: 'some string', number: 10 }New Methods & Classes
sleep
const asyncFunction = async () => {
await sleep(1000); // sleep 1000ms
console.log('hello');
};
asyncFunction();- Output after 1000ms:
helloKeyArray
const key_array = new KeyArray();
key_array.add('sun');
key_array.add(['moon', 'earth']);
console.log(key_array.get('sun')); // true
key_array.delete('sun');
console.log(key_array.get('sun')); // false
console.log(key_array);- Output:
KeyArray(2) [ 'moon', 'earth' ]