README
slqnest
slqnest is a package that allows for better features making JavaScript coding easier. This package is in testing, so there are a lot of bad features (see "Warnings" section)
Downloading
make sure you have npm
installed them run the terminal command:
$ npm install slqnest
it can be required without setting a variable:
require('slqnest');
What it does
as of this version...
- slqnest allows for
Array.prototype.forEach
to set values of an array,
// without slqnest
const array = [1, 2, 3];
array.forEach(element => {
element++;
});
console.log(array); // [1, 2, 3]
// with slqnest
require('slqnest');
const array = [1, 2, 3];
array.forEach(element => {
element++;
});
console.log(array); // [2, 3, 4]
- slqnest does the same for
for(param of param)
,
// without slqnest
const array = [1, 2, 3];
for(element of array) {
element++;
}
console.log(array); // [1, 2, 3]
// with slqnest
require('slqnest');
const array = [1, 2, 3];
for(element of array) {
element++;
}
console.log(array); // [2, 3, 4]
- slqnest will fix non-whole number addition and subtraction,
// without slqnest
console.log(0.1 + 0.2); // 0.30000000000000004
// with slqnest
require('slqnest');
console.log(0.1 + 0.2); // 0.3
Turning on and off
you can turn off slqnest by using the keyword 'no slq'
, and you can turn it back on by using the keyword 'use slq'
(kind of like 'use strict'
):
require('slqnest');
'no slq'; // turning off
const array = [1, 2, 3];
for(element of array) {
element++;
}
console.log(array); // [1, 2, 3]
'use slq'; // turning on
const array = [1, 2, 3];
array.forEach(element => {
element++;
})
console.log(array); // [2, 3, 4]
Warnings
⚠ slqnest is currently in development, there can be bugs and defects
- anything before
require('slqnest');
will be ran twice, while promises and intervals / timeouts will be terminated. (probably can't be fixed)
// before
console.log('before 1');
setTimeout(() => {
console.log('before 2');
}, 1000);
require('slqnest');
// after
console.log('after 1');
setTimeout(() => {
console.log('after 2');
}, 1000);
/* output:
before 1
after 1
after 2
*/
- nothing will happen with requiring a file that uses slqnest. (probably can be fixed)
// file1
require('slqnest');
module.exports = 'hello world';
// file2
const file1 = require('./file1');
console.log('hi'); // no response
console.log(file1); // no response
second argument of
Array.prototype.forEach
will be lost. (probably can be fixed)there can be up to 1-2 second downtime when running a file before it outputs anything, this is dependent on how big the file is. (probably can't be fixed)