npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@synapsecloud/lib-react

v0.0.6

Published

Helper library for web applications built on React Js

Downloads

171

Readme

lib-react

Lib-React is a specialized software library designed to enhance the development experience for web applications utilizing the React.js framework. It provides a collection of robust helper functions that streamline common tasks faced by developers, allowing them to focus on building dynamic user interfaces rather than getting bogged down by repetitive coding patterns. lib-react promotes best practices by offering reusable components and hooks that help maintain clean, maintainable code. Its comprehensive documentation and active community support make it an invaluable resource for both novice and experienced developers looking to leverage the full potential of React.js in their projects. By integrating lib-react into their workflow, developers can save time, reduce errors, and deliver high-quality web applications more efficiently.

Installation

Use Node Package Manager npm to install lib-react.

npm i @synapsecloud/lib-react

Usage

Hooks

useSet

import { useSet } from '@synapsecloud/lib-react';

function MyComponent(props) {
  const { add, delete, clear, has, forEach, values, size } = useSet();
  
  return (
    <div>
      <button onClick={() => {
        const a = size + 1; 
        add(a);
        console.log(has(a)); // true
        
        const b = a + 1;
        add(b);
        console.log(has(b)); // true

        forEach(value => console.log(value.toString() + ', ')); // {a}, {b},

        clear();
      }}>Submit</button>
    </div>
  );
}

useMap

import { useMap } from '@synapsecloud/lib-react';

function MyComponent(props) {
  const { get, set, delete, clear, has, forEach, values, size } = useMap();
  
  return (
    <div>
      <button onClick={() => {
        const a = size + 1; 
        set(a, 'hello');
        console.log(has(a)); // true
        
        const b = a + 1;
        add(b, 'hello world!');
        console.log(has(b)); // true

        forEach((value, key) => console.log(key, value.toString() + ', ')); // {a} 'hello', {b} 'world!',

        clear();
      }}>Submit</button>
    </div>
  );
}

useStack

import { useStack } from '@synapsecloud/lib-react';

function MyComponent(props) {
  const { push, pop, clear, peek, includes, size } = useStack();
  
  return (
    <div>
      <button onClick={() => {
        const a = size + 1; 
        push(a);
        console.log(includes(a)); // true
        
        const b = a + 1;
        push(b);
        console.log(includes(b)); // true

        console.log(peek()); // {b}
        console.log(pop()); // {b}

        console.log(peek()); // {a}
        console.log(pop()); // {a}

        clear();
      }}>Submit</button>
    </div>
  );
}

useQueue

import { useQueue } from '@synapsecloud/lib-react';

function MyComponent(props) {
  const { enqueue, dequeue, clear, peek, includes, size } = useQueue();
  
  return (
    <div>
      <button onClick={() => {
        const a = size + 1; 
        enqueue(a);
        console.log(includes(a)); // true
        
        const b = a + 1;
        enqueue(b);
        console.log(includes(b)); // true

        console.log(peek()); // {a}
        console.log(dequeue()); // {a}

        console.log(peek()); // {b}
        console.log(dequeue()); // {b}

        clear();
      }}>Submit</button>
    </div>
  );
}

useBrowserStorage

import { useBrowserStorage } from '@synapsecloud/lib-react';

function MyComponent(props) {
  const { get, set, remove, updatedAt, key, version } = useBrowserStorage('my-key', '0.0.1');
  
  return (
    <div>
      <button onClick={() => {
        console.log(get()); // null
        console.log(set('my-data-as-a-string')); // 'my-data-as-a-string'
        console.log(get()); // 'my-data-as-a-string'
        console.log(remove()); // 'my-data-as-a-string';
        console.log(get()); // null
        
      }}>Submit</button>
    </div>
  );
}

License

MIT