1.0.16 • Published 3 years ago

kodekita v1.0.16

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

kodekita

Kodekita is a collection of javascript code that can be reused without rewriting the code.


Daftar Isi


Installation

npm install --save kodekita

Usage

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 (
			<div>
				<h1>Hello Joko!</h1>
				<p>Happy Hacking! :)</p>
			</div>
		);
	}
}

export default App;

API

initGlobalTools

initGlobalTools( object:config ) will initiate a global variable or function that can be accessed freely without importing

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
NameDescriptionTypeConfig
window.devLog( all:log )same as console.log, but the logs will not be displayed after the production / npm run buildfunctiondevLog : true
window.devStatusGlobal boolean variable that contains true if running under developmentbooleandevStatus : true
window.localhostStatusGlobal boolean variable that contains true if running under localhostbooleanlocalhostStatus : 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 extensionbooleandisableReactDevTools : true

promiseAll

promiseAll( list:functions ) will execute multiple functions asynchronously

import { promiseAll } from "kodekita";
function showLog( ) {
	console.log( 'Im here!' );
}
promiseAll([ showLog, showLog, showLog ]);

isJsonString

isJsonString( string:jsonString ) will check and return true if string is a stringified JSON

import { isJsonString } from "kodekita";
const stringifiedJson = '{name:"Joko",gender:"male",city:"Bekasi"}';
isJsonString( stringifiedJson ); //true

idrCurrencyFormatter

idrCurrencyFormatter( number:currency ) will format integer into IDR currency format

import { idrCurrencyFormatter } from "kodekita";
idrCurrencyFormatter( 64000 ); //Rp 64000

idrCurrencyParser

idrCurrencyParser( string:currency ) will parse IDR currency into integer

import { idrCurrencyParser } from "kodekita";
idrCurrencyParser( 'Rp 64000' ); //64000

greeterText

greeterText( string:name ) will display greeter with name

import { greeterText } from "kodekita";

greeterText( 'Joko' );

setSession

setSession( string:header, string:value) stores data to Session Storage.

import { setSession } from "kodekita";

setSession( 'name', 'Joko' );

getSession

getSession( string:header ) get data from Session Storage.

import { getSession } from "kodekita";

getSession( 'name' );

deleteSession

deleteSession( string:header ) delete data from Session Storage.

import { deleteSession } from "kodekita";

deleteSession( 'name' );

clearSession

clearSession() clear all data from Session Storage.

import { clearSession } from "kodekita";

clearSession( );
1.0.16

3 years ago

1.0.15

3 years ago

1.0.14

3 years ago

1.0.13

3 years ago

1.0.12

3 years ago

1.0.11

3 years ago

1.0.10

3 years ago

1.0.9

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago