2.0.3 • Published 6 years ago

jsmp-infra-first-task v2.0.3

Weekly downloads
13
License
-
Repository
github
Last release
6 years ago

npm module for first task

Js code.

Package

You can find a package details npm.

# With npm
npm install jsmp-infra-first-task

Usage examples

// ES Modules
import {all} from 'jsmp-infra-first-task';
all([4, 2, 3], x => x > 1); // true

To import snippets with Node:

const all  = require('jsmp-infra-first-task').all;
all([4, 2, 3], x => x > 1);
const  {all}  = require('jsmp-infra-first-task').all;
all([4, 2, 3], x => x > 1);

Table of Contents

Array

String

Array

all

Returns true if the provided predicate function returns true for all elements in a collection, false otherwise.

Use Array.every() to test if all elements in the collection return true based on fn. Omit the second argument, fn, to use Boolean as a default.

const all = (arr, fn = Boolean) => arr.every(fn);
all([1, 2, 3]); // true ]

⬆ Back to top

any

Returns true if the provided predicate function returns true for at least one element in a collection, false otherwise.

Use Array.some() to test if any elements in the collection return true based on fn. Omit the second argument, fn, to use Boolean as a default.

const any = (arr, fn = Boolean) => arr.some(fn);
any([0, 1, 2, 0], x => x >= 2); // true

⬆ Back to top

String

isLowerCase

Checks if a string is lower case.

Convert the given string to lower case, using String.toLowerCase() and compare it to the original.

const isLowerCase = str => str === str.toLowerCase();
isLowerCase('abc'); // true
isLowerCase('a3@$'); // true
isLowerCase('Ab4'); // false

⬆ Back to top

2.0.3

6 years ago

2.0.2

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.0.0

6 years ago