GithubHelp home page GithubHelp logo

afiiif / dev-disk Goto Github PK

View Code? Open in Web Editor NEW
2.0 1.0 0.0 1.18 MB

A tiny utility library for JavaScript/TypeScript project

Home Page: https://www.npmjs.com/package/dev-disk

License: MIT License

JavaScript 4.05% TypeScript 95.95%
react utilities

dev-disk's Introduction

Dev Disk ๐Ÿ’ฝ

The tiny utility library for JavaScript/TypeScript project.

This library is intentionally minimalist, designed to handle most cases.
It's deliberately not built to handle rare cases to keep its size from becoming bloated.

Basically it is the improved version & unnecessary-utilities-removed version of my previous libraries:

Also, Dev Disk supports ESM & CommonJS โœ…
You can check it out at https://www.npmjs.com/package/dev-disk.

Composition

  • Vanilla JS ๐Ÿ‘‰ import { ... } from "dev-disk"
  • React JS ๐Ÿ‘‰ import { ... } from "dev-disk/react"

If you're interested in diving deeper, feel free to check out the source code.

Vanilla JS Utilities

Common Helpers

  • noop - Empty function
  • identity - Identity function
  • hasValue - Check if a value is not undefined and not null
  • isObject - Check if a value is object (Record<string, any>)
  • getValue - If the value is a function, it will get the returned value, otherwise it will get the value
  • getHash - Get stable hash (string) from object/array
  • swapKeyValue - Get a swaped key-value object
  • sleep - Delay the next operation for a specific duration
  • split2 - Split string into 2 parts
  • cn - A minimalist className utility
  • shallow - Shallow compare

Error Handling

  • createError - Create an Error instance with custom props
  • noThrow - Higher-order function to prevent a function throwing error when invoked
  • noReject - Higher-order function to prevent an async function throwing promise-rejection error when invoked

Data-Fetching Related

  • objectToQueryString - Convert object to search param (string)
  • queryStringToObject - Convert search param (string) to object
  • http - Minimalist abstraction for fetch API
    • http.get
    • http.post
    • http.put
    • http.delete
    • http.gql

Publish-Subscribe Pattern

  • initStore - Create vanilla JS store that can be subscribed
  • initStores - Same as initStore but for multiple stores, publish/subscribe/access the value using a store-key (that will be serialized into a string).

React JS Utilities

Global-State Manager Using Publish-Subscribe Pattern

dev-disk's People

Contributors

afiiif avatar

Stargazers

Yunus Bahtiar avatar Sinar avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.