Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@op-engineering/toolkit

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@op-engineering/toolkit

Toolkit useful functions

  • 0.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

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

Keywords

FAQs

Package last updated on 01 Jun 2024

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc