1.0.0 • Published 4 months ago

common-utils-core v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
4 months ago

common-utils-core

common utils LogUtils:print logs DateUtils:useful dateutils

Installation

npm install common-utils-core
#or
yarn add common-utils-core

API

DateUtils

functionDescriptionparamsreturn
dateFormat-moment,string:{default:"-"}string
datetimeFormat-moment,string:{default:"-"},string:{default:":"}string
timeFormat-moment,string:{default:":"}string
yearFormat-momentstring
monthDayFormat-moment,string:{default:"-"}string
getValidMomentDate-moment/stringmoment
getNow-voidmoment
format-moment/string,stringstring
findTheEffectiveAndEarliiestBetweenRangeDates-string,string,string,...,string,stringstring
getDifferWeeksBetweenTwoDates-moment/string,moment/stringnumber

LogUtils

functionDescriptionparamsreturn
setShowLog-booleanvoid
setLogLevel-string:{allow:"debug","info","warn","error"}void
debug-arrayvoid
info-arrayvoid
warn-arrayvoid
error-arrayvoid

How to use it

import {DateUtils,LogUtils} from "common-utils-core"; //es
// const {DateUtils,LogUtils} = require("common-utils-core");//commonjs
// const {DateUtils,LogUtils} = window["common-utils-core"];//html

const { DateUtils, LogUtils } = window["common-utils-core"];//html
LogUtils.debug("debug log");
LogUtils.info("info log");
LogUtils.warn("warn log");
LogUtils.error("error log");

LogUtils.debug("----------change level to warn------------");

LogUtils.setLogLevel("warn");//change level to warn
LogUtils.debug("debug log");
LogUtils.info("info log");
LogUtils.warn("warn log");
LogUtils.error("error log");

LogUtils.setLogLevel("debug");
LogUtils.debug("----------hide log------------");

LogUtils.setShowLog(false); //hide log
LogUtils.debug("debug log");
LogUtils.info("info log");
LogUtils.warn("warn log");
LogUtils.error("error log");

LogUtils.setShowLog(true); //hide log
LogUtils.debug(DateUtils.datetimeFormat(DateUtils.getNow()));

update

1.0.0 add DateUtils,LogUtils

1.0.0

4 months ago