Socket
Socket
Sign inDemoInstall

@dukai.net/tools

Package Overview
Dependencies
0
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @dukai.net/tools

Mixed tools and utility methods for both server and client side


Version published
Maintainers
1
Created

Readme

Source

tools

Utilities for both server and client side.

This module is part of the "Minimal Stack".

Methods:

NameDescription
guid(count)Using timestamp to generate a unique id, count provides length, default is 16
isObject(value)Checks if value is a real javascript object
isDate(value)Checks if value is a date instance
isFunction(value)Checks if value is a method
isAsyncFunction(value)Checks if value is an async method
isEmpty(value, type)Checks if value is empty (undefined or null) type default is 'string', can be 'number', 'object', 'array'
clone(obj)Recursive true deep clone of an object
random(min, max)Random integer between min and max values (inclusive)
shortNumber(value, options)Converts number to short version: 12300000 = 1.23M, options: kilo: 'k', mega: 'M'
formatNumber(value, options)Formats the number based on options: decimalCount: 2, decimal: '.', thousands: ','
formatPhone(value)Formats phone number
clearPhone(value)Clears phone formatting
validPhone(value)Checks if value is a valid phone
validEmail(value)Checks if value is a proper email address
validUrl(value)Checks if value is a proper url
escapeRegExp(value)Escapes special characters in value
replaceAll(str, search, value)Replaces all occurences string with another string
toCamelCase(str)converts to camel case format
toTitleCase(str)Converts to title case format
toAccentFree(str)Replaces all accent character with standard English one: ü = u, ó,ö.ő = o
toVariable(str)Converts to variable format
format(value, args)Formats text with variable points: format("Hello {0}, look {1}?", ['Jane', 'left'])
clientInfo()Returns with collected info from browser
addToEvents(handlers, event)Adds new "event" to handlers array
callEvents(handlers, args)Calls all elements of handlers array with args parameters
callEvent(handler, args)Calls a single handler method with arguments
interval(callback, wait, times)Alternative to setInterval. This one waits until previous cycle completed.
hashToList(obj, selected)Converting hash table to array of items with (value and text). If selected matches, then it will be added a selected: true to item.

Keywords

FAQs

Last updated on 17 Dec 2021

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc