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 🙏

© 2025 – Pkg Stats / Ryan Hefner

des-utilities

v1.0.4

Published

Reusable components for web development

Downloads

0

Readme

DES Utilities

DES - Design Synchrony

Provides reusuable components for development, together with easier, faster and simpler code base.

Installation

Install with npm

npm i des-utilities

Features

  • Simpler binding in classes (BindThis)
  • Easier state lifting (Call parent method)
  • Duplicate items and map items in an object or array into multiple component classes
  • Dynamic Component

Usage/Examples

Bind This

Simplifies the method binding process in classes (react or any language that uses similar binding methods).

(For now, it works with react js at the moment and contributions will be appreciated) For example, this:

import React from 'react';
import { BindThis } from 'des-utilities';

export default class NewClass extends React.Component {
    constructor(props){
        super(props);

        this.function1 = this.function1.bind(this);
        this.function2 = this.function2.bind(this);
        this.function3 = this.function3.bind(this);
    }
    ...
}

becomes

import React from 'react';
import { BindThis } from 'des-utilities';

export default class NewClass extends React.Component {
    constructor(props){
        super(props);

        BindThis(this, ['function1', 'function2', 'function3']);
    }
    ...
}

Call Parent Method

Easy state lifting in React js (especially).

Pass method name to child in react

...
import Rename from './rename';
import { BindThis } from 'des-utilities';
import { CallParentMethod } from 'des-utilities';
...

class parent extends React.Component{
    constructor(props){
        super(props);

        this.state = {
            name: ''
        }

        BindThis(this, [changeName]);
    }

    function changeName(name){
        ...
    }

    render () {
        return (
            <Rename changeName={this.changeName} />
        )
    }
    ...
}




class child extends React.Component{
    constructor(props){
        super(props);

        this.state = {
            name: ''
        }

        BindThis(this, [changeName]);
    }

    function changeName(){
        // call changeName method passed to child as prop and pass "name" as prop. props could be of any type
        CallParentMethod(this, this.props.changeName, this.state.name)
        ...
    }

    render () {
        return (
            <input type="text" value={this.state.name} />
            <button ... onClick={this.changeName} />
        )
    }
    ...
}

Duplicate items

Easily loop through an array or object, and render dynamic component, passing props (that are variables) through structureProps, as an object and function props (props that passes a function to the child) through functionProps.

Check documentation for details.

...
import { DuplicateItems } from 'des-utilities';
import GridItem from './components/GridItem';

export default class grid extends Component {
    render() {
        const obj = {
            name: 'abbey',
            description: 'a programmer by nature',
            image: './assets/img.jpg'
        }
        return (
            <>
                <h2 className="text-center">Loop through list</h2>
                <div className="grid gap-4 mt-6 md:mt-11 ">
                    <DuplicateItems items={obj} structure={GridItem} structureProps={{ name: 'name', description: 'description', image: 'image' }} />
                </div>
            </>
        )
    }
}
...

Dynamic Component

Allow you to dynamically call components

The objective was to allow easy use of react router useParam() hook in a class component, but can be used to dynamically call component

...
import { DynamicComponent } from 'des-utilities';

...

DynamicComponent(ComponentName)
...

will return

<ComponentName />

with it's props and url parameters from the current route, accessible at props.params, as used below

let parameter1 = this.props.params.parameter1;
let parameter2 = this.props.params.parameter2;
let parameter3 = this.props.params.parameter3;

and a route param, using react-router-dom can be accessed like below

url parameters in routes

...
<Route path="/profile/:id" element={<Profile />} />

...
https://www.testdomain.you/profile/1

can be accessed as

...
import React from 'react';
import { DynamicComponent } from 'des-utilities';
import HttpRequest from 'des-http-processor';
import { ProcessHttpMessage } from 'des-http-processor';
...

class Profile extends React.Component {
    constructor(props){
        super(props);

        HttpRequest()
        this.state = {
            user: {}
        }

        // fetch user
        HttpRequest('backend.testdomain.you/user', 'get', {user_id: this.props.params.userId}, ProcessHttpMessage).then((response) => {
            this.setState({
                user: response.data
            });
        }, (error) => {

            console.log(error.description)
        });
    }

    render() {
        return (
            ...
        );
    }
}

export default dynamicComponent(Profile);

Note: error message is extracted by the ProcessHttpMessage function passed to the HttpRequest function

Authors

Feedback

If you have any feedback, please reach out to us at [email protected]

Contributing

Contributions are always welcome!

See contributing.md for ways to get started.

Please adhere to this project's code of conduct.

License

MIT

Documentation

Documentation