@flavs/nodedash
v1.0.2
Published
Node v10 typescript test driven web app
Downloads
16
Maintainers
Readme
Test Node Typescript
Test Driven Node v10 Typescript Web App
nodedash v1.0.0
Import
_n._n_import
_n._n_modules
Require
_n.require
Date
_n.date
_n.now
_n.getTimestamp
_n.isDate
Math
_n.addDays
_n.subtractDays
Import
Import using esm
or TypeScript
Since
1.0.0
Example
import _n from 'nodedash'
_n.date('3/14/2019', 'uk')
// => 14 Mar 2019
_n.addDays('3/6/19', 1, '-')
// => 03-07-2019
_n.subtractDays('3/6/19', 1, '-')
// => 03-05-2019
Import individual ES Modules using esm
or TypeScript
Since
1.0.0
Example
import { addDate, subtractDate } from 'nodedash'
addDays('3/6/19', 1, '-')
// => 03-07-2019
subtractDays('3/6/19', 1, '-')
// => 03-05-2019
Require
Import using require
Since
1.0.0
Example
const _n = require('nodedash')
_n.date('3/14/2019', 'uk')
// => 14 Mar 2019
_n.addDays('3/6/19', 1, '-')
// => 03-07-2019
_n.subtractDays('3/6/19', 1, '-')
// => 03-05-2019
“Date” Methods
Computes input date
converts to string and returns with specified format
.
Since
1.0.0
Arguments
Date
(date): options arenew Date()
,timestamp
orstring
in valid date format. See example below.format
(string):
Returns
(string): Returns the date as a String in specified format.
Example
let any_nate = "1/07/2019"
_n.date(any_nate, '/')
// => 01/07/2019
_n.date(any_nate, '-')
// => 01-07-2019
_n.date(any_nate, '.')
// => 01.07.2019
_n.date(any_nate, 'MMM DD YYYY')
// => Jan 07 2019
_n.date(any_nate, 'england')
// => 07 Jan 2019
_n.date(any_nate, 'uk')
// => 07 Jan 2019
_n.date(any_nate, 'full')
// => Mon Jan 07 2019 00:00:00 GMT-0700 (Mountain Standard Time)
Gets the timestamp of the number of milliseconds that have elapsed since
the Unix epoch (1 January 1970 00
:00:00 UTC).
Since
1.0.0
Returns
(number): Returns the timestamp.
Example
const { defer } = require('lodash')
defer(function(stamp) {
console.log(_n.now() - stamp)
}, _n.now())
// => Logs milliseconds it took for the deferred invocation.
Gets the timestamp of the number of milliseconds that have elapsed since
date
argument. If date
is undefined
it gives milliseconds elapsed since
the Unix epoch (1 January 1970 00
:00:00 UTC).
Since
1.0.0
Arguments
Date
(date): to convert to timestamp.
Returns
(number): Returns the timestamp.
Example
_n.getTimestamp('July 4 1776')
// => 121244400000
_n.getTimestamp()
// => 1552353178563
// returns now timestamp
_n.getTimestamp('11/4/1973')
// => -6106035604000
Verifies if value
is a valid Date object
and valid Date
.
Since
1.0.0
Arguments
value
(*): The value to check.
Returns
(boolean): Returns true
if value
is a Date object
& valid Date
, else false
.
Example
_n.isDate('3/3/19')
// => true
_n.isDate(new Date())
// => true
_n.isDate('Jul 4 1776')
// => true
_n.isDate(25200000)
// => true
_n.isDate('3/33/19')
// => false
function getDate() {
return '1/1/19'
}
_n.isDate(getDate)
// => false
_n.isDate(getDate())
// => true
“Math” Methods
Input _nate
add nDays
with format
Since
1.0.0
Arguments
Date
(date):days
(number): to addformat
(string):
Example
const any_nate = '3/6/19'
_n.addDays(any_nate, 1, '-')
// => 03-07-2019
_n.addDays(any_nate, 2, '.')
// => 03.08.2019
_n.addDays(any_nate, 3, 'uk')
// => 09 Mar 2019
Input _nate
subtract nDays
with format
Since
1.0.0
Arguments
Date
(Date):days
(number): to subtractformat
(string):
Example
const any_nate = '3/6/19'
_n.subtractDays(any_nate, 1, '-')
// => 03-05-2019
_n.subtractDays(any_nate, 2, '.')
// => 03.04.2019
_n.subtractDays(any_nate, 3, 'uk')
// => 03 Mar 2019