All Projects → funbox → diamonds

funbox / diamonds

Licence: MIT license
A pile of shiny typed JS helpers for everyday usage

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to diamonds

dpytools
Collection of easy to use, beginner friendly but powerful, orthogonal tools to speed up discord bots development (discord.py)
Stars: ✭ 23 (+43.75%)
Mutual labels:  utilities, helpers-library
gut
🍱 yet another collection of go utilities & tools
Stars: ✭ 24 (+50%)
Mutual labels:  utilities
Puppy
Daily Use Utilities and Frameworks by .NET Core
Stars: ✭ 14 (-12.5%)
Mutual labels:  utilities
Jenkins-Pipeline-Utils
Global Jenkins Pipeline Library with common utilities.
Stars: ✭ 36 (+125%)
Mutual labels:  utilities
NCoVUtils
Utility functions for the 2019-NCoV outbreak
Stars: ✭ 27 (+68.75%)
Mutual labels:  utilities
ios
CoThings's iOS application. CoThings is a realtime counter for shared things.
Stars: ✭ 13 (-18.75%)
Mutual labels:  utilities
Milvasoft
Helper structures for .Net 6 projects.
Stars: ✭ 24 (+50%)
Mutual labels:  helpers-library
FunUtils
Some codes i wrote to help me with me with my daily errands ;)
Stars: ✭ 43 (+168.75%)
Mutual labels:  utilities
alsa-utils
The Advanced Linux Sound Architecture (ALSA) - utilities
Stars: ✭ 122 (+662.5%)
Mutual labels:  utilities
libra-code
quantum-dynamics-hub.github.io/libra/index.html
Stars: ✭ 33 (+106.25%)
Mutual labels:  utilities
framestack
Tools, Frameworks & Libraries to help you build your projects ✨
Stars: ✭ 27 (+68.75%)
Mutual labels:  utilities
whitelister
Simple, basic filtering and validation tool for Node.js.
Stars: ✭ 46 (+187.5%)
Mutual labels:  utilities
CircularArrays.jl
Multi-dimensional arrays with fixed size and circular indexing.
Stars: ✭ 19 (+18.75%)
Mutual labels:  utilities
microlibs-scala
No description or website provided.
Stars: ✭ 24 (+50%)
Mutual labels:  utilities
FlexDict
Easily work with deeply nested dictionaries and write clean code using FlexDict; a small subclass of dict. FlexDict provides automatic and arbitrary levels of nesting along with additional utility functions.
Stars: ✭ 71 (+343.75%)
Mutual labels:  utilities
kitty-theme-changer
Obsolete: use "kitty +kittens themes"
Stars: ✭ 26 (+62.5%)
Mutual labels:  utilities
Windows-911
Curated list of FREE emergency resources when you find yourself in the inevitable pickle with Windows. PRs welcome!
Stars: ✭ 24 (+50%)
Mutual labels:  utilities
php-lodash
php-lodash is a PHP utility library, similar to Underscore/Lodash.
Stars: ✭ 35 (+118.75%)
Mutual labels:  utilities
common
Utilities and base libraries for use across polkadot-js for Polkadot and Substrate. Includes base libraries, crypto helpers and cross-environment helpers. Full documentation & examples available.
Stars: ✭ 221 (+1281.25%)
Mutual labels:  utilities
MHW-Shop-Editor
Monster Hunter World Provisions Stockpile Shop Editor
Stars: ✭ 52 (+225%)
Mutual labels:  utilities

@funboxteam/diamonds

Set of diamonds

npm

This is a set of helpers that we use in the current projects and will probably use in the future ones.

All helpers are independent of each other, which means that your project's bundle won't be bloated by useless code.

По-русски

Contents

Rationale

When developers create projects they use a lot of small functions that are not connected to the project itself. Usually such functions are stored in folders like utils or helpers.

To prevent copy-pasting between a huge amount of projects we've created this package.

These functions are not aimed to be absolutely safe to unexpected usage. They do exactly what they say they do, and nothing else.

Installation

Add the package to deps:

npm install --save @funboxteam/diamonds 

Import functions:

import { getUniqueId } from '@funboxteam/diamonds';

List of helpers

It's easier to check every helper's source code rather than reading docs. But if you want some, here they are.

base64ToUint8Array

Converts Base64 string to a Uint8Array.

disableBodyScroll, enableBodyScroll

The first function disables scroll on the current page with the possibility to save the current scrolled position, the second one enables the scroll and restores its position if it was saved.

It's useful when you want to disable scroll e.g. while opening sidebar and enable it while closing.

camelToKebab

Converts camelCase string into kebab-case.

capitalize

Change the passed strings's first letter case to upper.

colorize

Returns passed params as string with color tags inside.

It's useful when you want to colorize logs in terminal.

datauriToBlob

Converts DataURI string into Blob instance.

It's useful when you need to send an image from online editor to the server.

debounce

Returns a debounced function that delays invoking callback until passed seconds have elapsed since the last time the debounced function was invoked.

It's useful when you have to handle flow of events but want to fire callback after the flow finishes.

deepClone

Returns deep clone of the passed object. Does not work with circular links.

It's useful when you need to deeply clone an object. Object.assign does not work in this case, because it creates a shadow copy.

equals

Deeply compares passed params.

findLast

Returns the value of the last element in the provided array that satisfies the provided testing function. Otherwise undefined.

formatBytes

Converts size in bytes to KB, MB, GB, etc.

formatNumberString

Formats a number (or a string with a number inside) using the passed format.

It's useful when you need to format, let's say, the cost of something.

formatPhoneNumberString

Formats a number (or a string with a number inside) by the mask of Russian MSISDNs.

getBrowserScrollbarWidth

Returns browser scrollbar width.

getDisplayName

Returns displayName for React HOC.

getImageOrientation

Extracts orientation from the passed images EXIF.

Example:

getImageOrientation.call(this, image, orientation => {
  let rotate;

  switch (orientation) {
    case 8:
      rotate = 270;
      break;
    case 6:
      rotate = 90;
      break;
    case 3:
      rotate = 180;
      break;
    default:
      rotate = 0;
  }

  this.setState({ rotate });
});

getObjectPath

Gets the value at path of object.

It's useful when you have to work with highly nested objects and don't want to write long conditionals. getObjectPath(obj, 'key1.key2.key3') and the work is done.

getPlural

Picks and returns a correct unit name for the passed number (according to Russian lang rules).

It's useful when it's important to pick correct unit name. E.g. “1 day”, “2 days”, etc.

getRandomNum

Returns pseudorandom number from the passed range.

getUniqueId

Returns a string generated by the pattern prefix-number where prefix is the passed param, but number is unique.

It's useful when you need a unique string that can be namespaced. E.g. for generating unique IDs for DOM elements.

hexToRgb

Converts HEX color string to RGB object.

isElementInViewport

Returns true when the passed DOM node is visible in the viewport (fully or partially depending on the params).

isEmailValid

Returns true when the passed string is a valid email.

isInputTypeSupported

Checks browser support of the passed type attribute value for input tag.

It's useful when you deal with old browsers.

isMobile

Returns true when UA is similar to mobile.

It is useful when you don't need a precise check (the checks that are used inside the script are quite simple).

kebabToCamel

Converts kebab-case string into camelCase.

queryStringToObject

Converts query-string into object.

objectToQueryString

Converts the passed object which contains primitive values or arrays of primitive values into the query string.

omit

Returns shallow copy of the passed object but without the passed keys.

E.g. in React: omit(this.props, 'mods', 'mix').

pick

Returns shallow copy of the passed object but with the passed keys only.

rgbToHex

Transforms RBG color object into HEX string.

storage

Makes it possible to use localStorage safely.

throttle

Transforms the passed callback into the function that delays callback firing.

It's useful when you want to react on some events but no than once an N ms.

Credits

Cute picture for the project was made by Igor Garybaldi.

Sponsored by FunBox

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].