Package Exports
- @stdlib/assert-is-current-year
- @stdlib/assert-is-current-year/lib/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@stdlib/assert-is-current-year) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
isCurrentYear
Test if a value is the current year.
Installation
npm install @stdlib/assert-is-current-yearUsage
var isCurrentYear = require( '@stdlib/assert-is-current-year' );isCurrentYear( value )
Tests if a value is either an integer equal to the current year or a Date object representing the current year.
var currentYear = require( '@stdlib/time-current-year' );
var bool = isCurrentYear( currentYear() );
// returns true
bool = isCurrentYear( 2021 );
// returns falseExamples
var currentYear = require( '@stdlib/time-current-year' );
var isCurrentYear = require( '@stdlib/assert-is-current-year' );
var bool = isCurrentYear( new Date() );
// returns true
bool = isCurrentYear( currentYear() );
// returns true
bool = isCurrentYear( 2021 );
// returns false
bool = isCurrentYear( null );
// returns falseCLI
Installation
To use the module as a general utility, install the module globally
npm install -g @stdlib/assert-is-current-yearUsage
Usage: is-current-year [options] [<year>]
Options:
-h, --help Print this message.
-V, --version Print the package version.
--split sep Delimiter for stdin data. Default: '/\\r?\\n/'.Notes
If the split separator is a regular expression, ensure that the
splitoption is either properly escaped or enclosed in quotes.# Not escaped... $ echo -n $'1998\n1999' | is-current-year --split /\r?\n/ # Escaped... $ echo -n $'1998\n1999' | is-current-year --split /\\r?\\n/
The implementation ignores trailing delimiters.
Examples
$ is-current-year 2011
falseTo use as a standard stream,
$ echo -n 1914 | is-current-year
falseBy default, when used as a standard stream, the implementation assumes newline-delimited data. To specify an alternative delimiter, set the split option.
$ echo -n '2001\t2002' | is-current-year --split '\t'
false
falseNotice
This package is part of stdlib, a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.
For more information on the project, filing bug reports and feature requests, and guidance on how to develop stdlib, see the main project repository.
Community
License
See LICENSE.
Copyright
Copyright © 2016-2023. The Stdlib Authors.