Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
NotificationsYou must be signed in to change notification settings

OP-Engineering/toolkit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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";functionmyComponent(){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";asyncfunctionfoo(){awaitsleep(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 consoleconstmyObj={  ...// some complex obj}debug(myObj)// Will pretty print an object to the RN console

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp