Some alternative implementations for common interfaces, classes etc.
Data reading usage:
import { getItem, setItem } from 'asyncstorage-alt';
async function readData() {
const values = {};
values['get_via_array'] = await getItem(['id', 'name', 'email']);
values['get_directly'] = await getItem('id');
console.log(values);
}
Output:
{
"get_via_array": {
"id": 1,
"name": "Akın Özgen",
"email": "akinozgen17@outlook.com"
},
"get_directly": 1
}
Data writing usage:
import { getItem, setItem } from 'asyncstorage-alt';
async function writeData() {
// Multi definition
await setItem({ id: 1, name: 'Akın Özgen', email: 'akinozgen17@outlook.com' });
// Single definition
await setItem('id', 1);
}
import http_build_query from 'http_build_query';
const loginPayload = {
username: 'root',
password: 'toor'
};
console.log(http_build_query(loginPayload));
Output:
username=root&password=toor
import n2a from 'nodelist_to_array.js';
const rows = document.querySelectorAll('tr');
console.log(n2a(rows));
import ins from 'insister.js';
// Parameters:
// (ins): insister (which is this function)
// (_ => prompt("Accept?") !== "yes"): condition (if returns false, function repeats itself)
// (_ => alert("Thanks")): callback (runs if condtion is true)
ins(ins, _ => prompt("Accept?") !== "yes", _ => alert("Thanks"));
/**
* asteriskMask($string: string, $length: number, $beginning: bool);
*
*/
require_once 'string-mask-php.php';
$myUnprotectedPhoneNumber = '+90 588 4777 777 777 44';
echo asteriskMask($myUnprotectedPhoneNumber, 3) . "\n";
echo asteriskMask($myUnprotectedPhoneNumber, 5, true) . "\n";
echo asteriskMask('root', 5); // If length greater than strlen('root') new length is strlen('root') / 2
// Output: +90 588 4777 777 77***
// *****88 4777 777 77 44
// ro**