Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

extension-props

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

extension-props

A utility library delivering some additional utility functions.

  • 0.9.8
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-66.67%
Maintainers
1
Weekly downloads
 
Created
Source

extension-props

A utility library delivering some additional utility functions.

Installation

npm install extension-props
# or
yarn add extension-props

Usage

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();
    

String

  • forInstance(str): checks whether v is a string.
    • Variations:
      • StringType.forInstance(str)
      • String.forInstance(str)
  • isBlank(str): return true, if v string is blank.
    • Variations:
      • StringType.isBlank(str)
      • String.isBlank(str)
  • isNotBlank(str): return true, if v string is not blank.
    • Variations:
      • StringType.isBlank(str)
      • String.isBlank(str)
  • isEmpty(): checks a string is empty.
    • Variations:
      • StringType.valueOf(str).isEmpty()
      • String.prototype.isEmpty()
  • isNotEmpty(): checks a string is not empty.
    • Variations:
      • StringType.valueOf(str).isNotEmpty()
      • String.prototype.isNotEmpty()
  • equals(another): checks a string is equals with another string.
    • Variations:
      • 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.
    • Variations:
      • 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.
    • Variations:
      • 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.
    • Variations:
      • StringType.replacePlaceholders(str, map)
      • String.replacePlaceholders(str, map)
      • StringType.valueOf(str).replacePlaceholders(map)
      • String.prototype.replacePlaceholders(map)

Function

  • forInstance(func): checks whether f is a function.
    • Variations:
      • FunctionType.forInstance(func)
      • Function.functionForInstance(func)
  • defineFunction(name, prototype): define a function with dynamic name.
    • Variations:
      • 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.
    • returns a function.
  • isCallable(func): checks whether f function is callable.
    • Variations:
      • 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.
    • Variations:
      • FunctionType.isNormalFunction(func)
      • Function.isNormalFunction(func)
  • isAsyncFunction(func): checks whether f is an async function.
    • Variations:
      • FunctionType.isAsyncFunction(func)
      • Function.isAsyncFunction(func)
  • isSyncFunction(func): checks whether f is a sync function (negative of isAsyncFunction).
    • Variations:
      • FunctionType.isSyncFunction(func)
      • Function.isSyncFunction(func)
  • isArrowFunction(func): checks whether f is an arrow function.
    • Variations:
      • FunctionType.isArrowFunction(func)
      • Function.isArrowFunction(func)
  • isNonArrowFunction(func): negative of isArrowFunction.
    • Variations:
      • FunctionType.isNonArrowFunction(func)
      • Function.isNonArrowFunction(func)
  • clone(): clone a function.
    • Variations:
      • FunctionType.valueOf(func).clone()
      • Function.prototype.clone()

Class

  • forInstance(cls): checks whether c is a class.
    • Variations:
      • ClassType.forInstance(cls)
      • Function.classForInstance(cls)
  • defineClass(name, superclass, prototype): define a class with dynamic name.
    • Variations:
      • 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.
    • return a class.
  • isES6Class(cls): checks whether c is an es6 class.
    • Variations:
      • ClassType.isES6Class(cls)
      • Function.isES6Class(cls)
  • preventInheritingClass(obj, classDefinition, except): prevent inheriting class.
    • Variations:
      • 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.
    • throw a OverridingError exception, if obj is an instance of a class, and it is not allowed to inherit the classDefinition class.
    • return false, if obj is an instance of a class, and it is not subclass of classDefinition class.
    • return true, if obj is an instance of a class, and it is allowed to inherit the classDefinition class.
    • Recommended: Put this function into the constructor.
  • preventOverrideFunction(obj, classDefinition, functions): prevent overriding of functions.
    • Variations:
      • 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.
    • throw a OverridingError exception, if obj contains a function, and it is not allowed to override in the subclass of the classDefinition class.
    • return false, if obj is an instance of a class, and it is not subclass of classDefinition class.
    • return true, if no function is prevented, it is contained in subclasses.
    • Recommended: Put this function into the constructor.

Object

  • getAllPropertyNames(obj): returns an array of all properties of a given object.
    • Variations:
      • ObjectType.getAllPropertyNames(obj)
      • Object.getAllPropertyNames(obj)
  • getAllPropertyDescriptor(obj, prop): returns a property descriptor for a property of a given object.
    • Variations:
      • ObjectType.getAllPropertyDescriptor(obj, prop)
      • Object.getAllPropertyDescriptor(obj, prop)
  • getAllPropertyDescriptors(obj): returns an array of all property descriptors of a given object.
    • Variations:
      • ObjectType.getAllPropertyDescriptors(obj)
      • Object.getAllPropertyDescriptors(obj)
  • isBlank(obj): return true, if obj = undefined or obj = null.
    • Variations:
      • ObjectType.isBlank(obj)
      • Object.isBlank(obj)
  • isNotBlank(obj): return true, if obj != undefined and obj != null.
    • Variations:
      • ObjectType.isNotBlank(obj)
      • Object.isNotBlank(obj)

Regex

  • forInstance(reg): checks whether v is a regex.
    • Variations:
      • RegexType.forInstance(reg)
      • RegExp.forInstance(reg)
  • escape(str): escape regex expression special characters.
    • Variations:
      • RegexType.escape(str)
      • RegExp.escape(str)
  • matchWords(str): create a regex string for checks match with the words in str string.
    • Variations:
      • RegexType.matchWords(str)
      • RegExp.matchWords(str)

Array

  • forInstance(arr): checks whether v is a array.
    • Variations:
      • ArrayType.forInstance(arr)
      • Array.forInstance(arr)
  • isBlank(arr): return true, if v array is blank.
    • Variations:
      • ArrayType.isBlank(arr)
      • Array.isBlank(arr)
  • isNotBlank(arr): return true, if v array is not blank.
    • Variations:
      • ArrayType.isNotBlank(arr)
      • Array.isNotBlank(arr)
  • isEmpty(): checks a array is empty.
    • Variations:
      • ArrayType.valueOf(str).isEmpty()
      • Array.prototype.isEmpty()
  • isNotEmpty(): checks a array is not empty.
    • Variations:
      • ArrayType.valueOf(str).isNotEmpty()
      • Array.prototype.isNotEmpty()
  • equals(another): checks a array is equals with another array.
    • Variations:
      • 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.
    • Variations:
      • ArrayType.valueOf(str).virtualGet(index)
      • Array.prototype.virtualGet(index)
  • insert(index, ...elements): insert elements into the specified position.
    • Variations:
      • 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.
    • Variations:
      • ArrayType.valueOf(str).lastIndexOf(element)
      • Array.prototype.lastIndexOf(element)

Keywords

FAQs

Package last updated on 24 Apr 2019

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc