ray-taken
v2.0.0
Published
A arguments extractor for ray-userland. Use this library to become careless about your arguments!
Downloads
10
Maintainers
Readme
ray-taken
A arguments extractor for ray-userland. Use this library to become careless about your arguments! A very good library to work with Arrays too!
Installation
Use the following command to install with NPM:
npm i ray-taken --save
Import as taken
:
const taken = require('ray-taken');
Usage
Example:
const taken = require('ray-taken');
const newArray = taken
.take([1,2,3, "a", "b", "xyz"])
.getArgsOfType("number")
.value;
console.log(newArray); // logs [1,2,3]
Methods available:
.logTypes
: Returns an Array of dataTypes available..commonRegex
: Returns an Array of commonly used Regex Patterns..take(myArray)
: Takes an array. Same astaken.value = myArray
. We always need to take an array in question to begin working with it!.getArgsOfType(dataType)
: Takes a string like "number", "string", "function", "object", "undefined", etc. and returns all items of that data-type..overArray(Array, callback)
: Goes over each item of an array, passing the said item to the provided callback function..union(ArrayB)
: Performs the logical union operation on the "taken" Array and the provided "ArrayB". Like "AUB"!.subtraction(ArrayB)
: Performs the logical subtraction operation..intersection(argsB)
: Performs the logical intersection operation..getArgsOfRegex(regex)
: Gets all the items of the "taken" Array that match the provided "regex"..getNumArgs()
: Gets all the items of the "taken" Array that are numbers..getStrArgs()
: Gets all the items of the "taken" Array that are strings..getFuncArgs()
: Gets all the items of the "taken" Array that are functions..getObjArgs()
: Gets all the items of the "taken" Array that are Objects, includingnull
and other non-primitive dataTypes and non-functions (has a .call())..getBoolArgs()
: Gets all the items of the "taken" Array that are Booleans..getPortNums()
: Gets all the items of the "taken" Array that are port numbers..getNodeNames()
: Gets all the items of the "taken" Array that are node names. Basically all strings that have "/" as the first character..getDirNames()
: Gets all the items of the "taken" Array that are directory names. Basically all strings that have "/" as the last character..getFileNames()
: Gets all the items of the "taken" Array that are file names. Basically all strings that have "/" character absent..getAbsUnixPaths()
: Get all items of the "taken" Array that are absolute unix paths. Basically all strings that have "/home" as the first 5 characters..getAbsWinPaths()
: Get all items of the "taken" Array that are absolute Windows paths. Basically all strings that have the first 2 characters like "C:", "D:", "E:", etc..getAbsPaths()
: Get all items of the "taken" Array that are absolute paths. Basically a combination of.getAbsUnixPaths()
and.getAbsWinPaths()
.More comming soon!
To find the values of these methods use the .value
property, all methods are chainable, hence return their parent object.
License
MIT License
Copyright (c) 2021 Ray Voice
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.