mkdird
Version:
Make a directory on your OS's desktop with mkdird CLI
36 lines (34 loc) • 1.05 kB
JavaScript
// Copyright (c) 2020 Thomas G. drozerah@gmail.com
// All rights reserved.
// This source code is licensed under the MIT license found in the
// LICENSE file in the root directory of this source tree.
/**
*
* Check if a given string contains any rejected characters
* from a given array of substrings
*
* Method:
*
* - we use Array.prototype.some() to check if the input
* string contains at least one of the subtrings stored
* in the toReject array
*
* - the function return true if the string
* contains at least one of the substring or false if not
*
* @example Example usage:
*
* isReject('foo', ['foo','bar']) // true
* isReject('foo', ['bar','baz']) // false
*
* @param {string} input the string to check
* @param {array} toReject the array of rejected substrings
* @return {boolean} boolean
* @author Drozerah https://github.com/Drozerah
*
*/
const isReject = (input, toReject) => toReject.some(elm => input.includes(elm))
/**
* Exports
*/
module.exports = {isReject}