GithubHelp home page GithubHelp logo

toolkit's Introduction

OSP Toolkit

In every project I work I end up needing the same bunch of functions. This is just a repo which contains them so I can easily install them and import them.

yarn add osp-toolkit

Constants

Some shorthand costants for React Native.

import { isIOS, isAndroid, ANDROID_VERSION, IOS_VERSION } from "osp-toolkit";

Hooks

Although hooks are not my favorite, sometimes there are useful patterns.

import { useBoolean } from "osp-toolkit";

function myComponent() {
  const [isFoo, fooOn, fooOff] = useBoolean();
}

Invariant checks

Invariant checks allow to assure the state of your app, by default they crash on releases so you better have error tracking via Sentry or similar set up.

import { invariant, nullthrows } from "osp-toolkit";

invariant(myVar === "foo", "myVar does not match, this crashes");

nullthrows(myVar, "myVar is null, this is crashes");

Sleep

A simple sleep function for async contexts

import { sleep } from "osp-toolkit";

async function foo() {
  await sleep(500);
}

Debugging

I love logging to console, so there are a couple utilities inserted on the global namespace that make your logs a little easier to visually parse

marker(`1`) // Outputs πŸ”·πŸ”·πŸ”·πŸ”·πŸ”·πŸ”·πŸ”·πŸ”·πŸ”·πŸ”·πŸ”·πŸ”· MARK ${i} πŸ”·πŸ”·πŸ”·πŸ”·πŸ”·πŸ”·πŸ”·πŸ”·πŸ”·πŸ”·πŸ”·πŸ”·πŸ”·πŸ”· to console

const myObj = {
  ...
  // some complex obj
}
debug(myObj) // Will pretty print an object to the RN console

toolkit's People

Contributors

ospfranco avatar

Stargazers

Salief Lewis avatar  avatar George Jor avatar Yahor Tsimashenka avatar ik5 avatar Mahmoud Mortada avatar Alessandro Arnodo avatar Wicak avatar Muhammad Saeed avatar Ahmet Biçer avatar  avatar Md  Anisur Rahman avatar

Watchers

 avatar  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.