Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
extension-props
Advanced tools
A utility library delivering some additional utility functions.
npm install extension-props
# or
yarn add extension-props
You can use this utilities by two way:
Use utility functions through the provided objects likes ObjectType, ArrayType, ClassType, FunctionType, RegexType, StringType. (Recommend)
const {
ObjectType,
ArrayType,
ClassType,
FunctionType,
RegexType,
StringType
} = require('extension-props');
Load additional utility functions into global objects likes String, Function, Object, Array, RegExp.
require('extension-props').extend();
forInstance(str)
: checks whether v is a string.
StringType.forInstance(str)
String.forInstance(str)
isBlank(str)
: return true, if v string is blank.
StringType.isBlank(str)
String.isBlank(str)
isNotBlank(str)
: return true, if v string is not blank.
StringType.isBlank(str)
String.isBlank(str)
isEmpty()
: checks a string is empty.
StringType.valueOf(str).isEmpty()
String.prototype.isEmpty()
isNotEmpty()
: checks a string is not empty.
StringType.valueOf(str).isNotEmpty()
String.prototype.isNotEmpty()
equals(another)
: checks a string is equals with another string.
StringType.valueOf(str).equals(another)
String.prototype.equals(another)
equalsIgnoreCase(another)
: checks a string is equals with another string on the basis of content of the string irrespective of case of the string.
StringType.valueOf(str).equalsIgnoreCase(another)
String.prototype.equalsIgnoreCase(another)
replaceAll(str, search, replacement)
: returns a new string with all matches of a pattern replaced by a replacement.
StringType.replaceAll(str, search, replacement)
String.replaceAll(str, search, replacement)
StringType.valueOf(str).replaceAll(search, replacement)
String.prototype.replaceAll(search, replacement)
replacePlaceholders(str, map)
: returns a new string with all matches of each key in the map replaced by its value.
StringType.replacePlaceholders(str, map)
String.replacePlaceholders(str, map)
StringType.valueOf(str).replacePlaceholders(map)
String.prototype.replacePlaceholders(map)
forInstance(func)
: checks whether f is a function.
FunctionType.forInstance(func)
Function.functionForInstance(func)
defineFunction(name, prototype)
: define a function with dynamic name.
FunctionType.defineFunction(name, prototype)
Function.defineFunction(name, prototype)
FunctionType.valueOf(prototype).defineFunction(name)
Function.prototype.defineFunction(name)
name
: is the name of the function.prototype
(option): is a function that determines the content of the function being created.isCallable(func)
: checks whether f function is callable.
FunctionType.isCallable(func)
Function.isCallable(func)
isNormalFunction(func)
: checks whether f is a normal function, that means that f is not an async function nor an arrow function.
FunctionType.isNormalFunction(func)
Function.isNormalFunction(func)
isAsyncFunction(func)
: checks whether f is an async function.
FunctionType.isAsyncFunction(func)
Function.isAsyncFunction(func)
isSyncFunction(func)
: checks whether f is a sync function (negative of isAsyncFunction).
FunctionType.isSyncFunction(func)
Function.isSyncFunction(func)
isArrowFunction(func)
: checks whether f is an arrow function.
FunctionType.isArrowFunction(func)
Function.isArrowFunction(func)
isNonArrowFunction(func)
: negative of isArrowFunction.
FunctionType.isNonArrowFunction(func)
Function.isNonArrowFunction(func)
clone()
: clone a function.
FunctionType.valueOf(func).clone()
Function.prototype.clone()
forInstance(cls)
: checks whether c is a class.
ClassType.forInstance(cls)
Function.classForInstance(cls)
defineClass(name, superclass, prototype)
: define a class with dynamic name.
ClassType.defineClass(name, superclass, prototype)
Function.defineClass(name, superclass, prototype)
ClassType.valueOf(superclass).defineClass(name, prototype)
Function.prototype.defineClass(name, prototype)
name
: is the name of the class.superclass
(option): specify a super class.prototype
(option): is a function that determines the content of constructor of the class being created.isES6Class(cls)
: checks whether c is an es6 class.
ClassType.isES6Class(cls)
Function.isES6Class(cls)
preventInheritingClass(obj, classDefinition, except)
: prevent inheriting class.
ClassType.preventInheritingClass(obj, classDefinition, except)
Object.preventInheritingClass(obj, classDefinition, except)
ClassType.valueOf(obj).preventInheritingClass(classDefinition, except)
Object.prototype.preventInheritingClass(classDefinition, except)
obj
: is an instance of subclass of classDefinition class.classDefinition
: is a superclass.except
(option): is white list, designate classes that are allowed to inherit.preventOverrideFunction(obj, classDefinition, functions)
: prevent overriding of functions.
ClassType.preventOverrideFunction(obj, classDefinition, functions)
Object.preventOverrideFunction(obj, classDefinition, functions)
ClassType.valueOf(obj).preventOverrideFunction(classDefinition, functions)
Object.prototype.preventOverrideFunction(classDefinition, functions)
obj
: is an instance of subclass of classDefinition class.classDefinition
: is a superclass.functions
: is an array of functions need to prevent override.getAllPropertyDescriptor(obj)
: returns an array of all properties of a given object.
ObjectType.getAllPropertyDescriptor(obj)
Object.getAllPropertyDescriptor(obj)
getAllPropertyDescriptor(obj, prop)
: returns a property descriptor for a property of a given object.
ObjectType.getAllPropertyDescriptor(obj, prop)
Object.getAllPropertyDescriptor(obj, prop)
getAllPropertyDescriptors(obj)
: returns an array of all property descriptors of a given object.
ObjectType.getAllPropertyDescriptors(obj)
Object.getAllPropertyDescriptors(obj)
isBlank(obj)
: return true, if obj = undefined or obj = null.
ObjectType.isBlank(obj)
Object.isBlank(obj)
isNotBlank(obj)
: return true, if obj != undefined and obj != null.
ObjectType.isNotBlank(obj)
Object.isNotBlank(obj)
forInstance(reg)
: checks whether v is a regex.
RegexType.forInstance(reg)
RegExp.forInstance(reg)
escape(str)
: escape regex expression special characters.
RegexType.escape(str)
RegExp.escape(str)
matchWords(str)
: create a regex string for checks match with the words in str string.
RegexType.matchWords(str)
RegExp.matchWords(str)
forInstance(arr)
: checks whether v is a array.
ArrayType.forInstance(arr)
Array.forInstance(arr)
isBlank(arr)
: return true, if v array is blank.
ArrayType.isBlank(arr)
Array.isBlank(arr)
isNotBlank(arr)
: return true, if v array is not blank.
ArrayType.isNotBlank(arr)
Array.isNotBlank(arr)
isEmpty()
: checks a array is empty.
ArrayType.valueOf(str).isEmpty()
Array.prototype.isEmpty()
isNotEmpty()
: checks a array is not empty.
ArrayType.valueOf(str).isNotEmpty()
Array.prototype.isNotEmpty()
equals(another)
: checks a array is equals with another array.
ArrayType.valueOf(str).equals(another)
Array.prototype.equals(another)
virtualGet(index)
: get value at index. You will still get a value even if the index is out of bounds.
ArrayType.valueOf(str).virtualGet(index)
Array.prototype.virtualGet(index)
insert(index, ...elements)
: insert elements into the specified position.
ArrayType.valueOf(str).insert(index, ...elements)
Array.prototype.insert(index, ...elements)
lastIndexOf(element)
: returns the last index at which a given element can be found in the array, or -1 if it is not present.
ArrayType.valueOf(str).lastIndexOf(element)
Array.prototype.lastIndexOf(element)
FAQs
A utility library delivering some additional utility functions.
The npm package extension-props receives a total of 0 weekly downloads. As such, extension-props popularity was classified as not popular.
We found that extension-props demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.