JSPM

@stdlib/assert-is-current-year

0.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 3
  • Score
    100M100P100Q30629F
  • License Apache-2.0

Test if a value is the current year.

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

NPM version Build Status Coverage Status

Test if a value is the current year.

Installation

npm install @stdlib/assert-is-current-year

Usage

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 false

Examples

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 false

CLI

Installation

To use the module as a general utility, install the module globally

npm install -g @stdlib/assert-is-current-year

Usage

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 split option 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
false

To use as a standard stream,

$ echo -n 1914 | is-current-year
false

By 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
false

Notice

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

Chat


License

See LICENSE.

Copyright © 2016-2023. The Stdlib Authors.