javascript reusable code collection
npm install kodekitashell
npm install --save kodekita
`
Usage
`js
import React, { Component } from "react";
import { initGlobalTools } from "kodekita";
initGlobalTools({ devLog: true, devStatus: true });
class App extends Component {
componentDidMount( ) {
/* same as console.log, but the logs will not be displayed after the production / npm run build /
window.devLog( Dev Status: ${ window.devStatus } );
}
render( ) {
return (
Hello Joko!
Happy Hacking! :)
);
}
}
export default App;
`
API
$3
initGlobalTools( object:config ) will initiate a global variable or function that can be accessed freely without importing
`js
import { initGlobalTools } from "kodekita";
// call on the root component index.js
initGlobalTools({ devStatus: true, devLog: true });
console.log( window.devStatus ); // return true if it is under development
window.devLog( 'this message will not appear after production!' ); //can be used to view logs only during development
`
Name | Description | Type | Config
--------|---------- | ----|------
window.devLog( all:log ) | same as console.log, but the logs will not be displayed after the production / npm run build | function | devLog : true
window.devStatus | Global boolean variable that contains true if running under development | boolean | devStatus : true
window.localhostStatus| Global boolean variable that contains true if running under localhost | boolean|localhostStatus : true
variables and functions are not needed*| Configuring to disable React Developer Tools extension. This feature is only needed if the browser uses the React Developer Tools extension |boolean|disableReactDevTools : true
$3
promiseAll( list:functions ) will execute multiple functions asynchronously
`js
import { promiseAll } from "kodekita";
function showLog( ) {
console.log( 'Im here!' );
}
promiseAll([ showLog, showLog, showLog ]);
`
$3
isJsonString( string:jsonString ) will check and return true if string is a stringified JSON
`js
import { isJsonString } from "kodekita";
const stringifiedJson = '{name:"Joko",gender:"male",city:"Bekasi"}';
isJsonString( stringifiedJson ); //true
`
$3
idrCurrencyFormatter( number:currency ) will format integer into IDR currency format
`js
import { idrCurrencyFormatter } from "kodekita";
idrCurrencyFormatter( 64000 ); //Rp 64000
`
$3
idrCurrencyParser( string:currency ) will parse IDR currency into integer
`js
import { idrCurrencyParser } from "kodekita";
idrCurrencyParser( 'Rp 64000' ); //64000
`
$3
greeterText( string:name ) will display greeter with name
`js
import { greeterText } from "kodekita";
greeterText( 'Joko' );
`
$3
setSession( string:header, string:value) stores data to Session Storage.
`js
import { setSession } from "kodekita";
setSession( 'name', 'Joko' );
`
$3
getSession( string:header ) get data from Session Storage.
`js
import { getSession } from "kodekita";
getSession( 'name' );
`
$3
deleteSession( string:header ) delete data from Session Storage.
`js
import { deleteSession } from "kodekita";
deleteSession( 'name' );
`
$3
clearSession() clear all data from Session Storage.
`js
import { clearSession } from "kodekita";
clearSession( );
``