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

kyc

v0.1.21

Published

This package handles all api connections while receiving data and built DOM about your HTML code template.

Downloads

26

Readme

KYC Logo

KYC

🥁 Fetch’ ing data from web services is an important and essential part of the web development. Also there’re some routines after then fetching the data!

  • looping data
  • caching
  • creating content

KYC manages this routine in a smart way for you. Just customise KYC and enjoy the convenience.

KYC serves you:

  • [x] Easy setup for API connection
  • [x] Easy content rendering over server response
  • [x] Caching response
  • [x] Setting expire time for cache
  • [x] API quota saving
  • [x] Bandwidth saving
  • [x] Performance improving

Did you know? KYC works with all JS base technologies... Like React, React Native, Type Script, Angular, Ionic, Vue, etc.

What to get?

  • Fetched and parsed output of your request

    OR

  • Array of your components which are prepared with output of your request

What to set?

  • url (string) - The end point URL for the HTTP request. This is an only must parameter.
  • settings (Object) - Any settings from the list below. All these are optional.
  • settings.method (string) - HTTP request method type (i.e. GET, POST, ...).
  • settings.headers (Object) - HTTP request headers.
  • settings.options (Object) - HTTP request options.
  • settings.parser (string) - Promise-based methods to access the body in various formats(json, text, formData, blob or arrayBuffer ).
  • settings.log (boolean) - Log parsed response on console.
  • settings.key (string) - Key or key chain (i.e. response.data.informations).
  • settings.component (function) - Callback function. Receives array members one by one as parameter.
  • settings.target (string) - CSS selector of target element on body for inserting rendered component (i.e. body, #id, .class-name)
  • settings.timeDiff (string) - Time difference to expire data on local storage (i.e. 123, 123s, 123m, 123h, 123d, 123w, 123y).
  • settings.sameDay (boolean) - Same day control to expire data on local storage.
  • settings.totalLimit (number) - Limit total request limit count by kyc from now on. Don't set it to remove the limit.
  • settings.errorHandler (function) - Error handler function.

How to install & import

$: npm install kyc
import kyc from 'kyc';

How to use in React

import kyc from 'kyc';
import CustomComponent from './components/CustomComponent';

let url = '';
let headers = {};
let key = '';
let timeDiff = '1d';
let component = (item) => {
    return (
        <CustomComponent 
            imgSrc = {item.background} 
            title = {item.title}
        />
    );
}

kyc(url,{ headers, key, component, timeDiff}).then(output => {
    /*output will be array of your components*/
});

React sample with hooks

App.js

import './App.css';
import kyc from 'kyc';
import Card from './components/Card';
import {useState, useEffect} from 'react';

function App() {

 const [countries, setCountries] = useState();

 useEffect(() => {
   let url = 'https://restcountries.eu/rest/v2/all';
   let timeDiff = '1d';
   let log = 'true';
   let component = (item) => {
     return (
       <Card 
         imgSrc = {item.flag} 
         title = {item.name}
       />
     );
   }

   kyc(url, {log, timeDiff, component})
   .then(output => setCountries(output));
 }, []);

 return (
   <div className="App">
     <h1>KYC Sample with countries</h1>
     {countries}
   </div>
 );
}

export default App;

Card.js

import './Card.css';

export default function (props) {
 return (
   <div className = "card">
     <img src = {props.imgSrc}/>
     <h3>{props.title}</h3> 
   </div>
 );
}

GitHub Repo

GitHub Pages

React sample with classes

🥁 Samples are coming soon...

For sure, you can try yourself and even contribute with us!

How to use in Angular

🥁 Instructions are coming soon...

For sure, you can try yourself and even contribute with us!

Angular Sample

🥁 Samples are coming soon...

For sure, you can try yourself and even contribute with us!

How to use in Vue

🥁 Instructions are coming soon...

For sure, you can try yourself and even contribute with us!

Vue Sample

🥁 Samples are coming soon...

For sure, you can try yourself and even contribute with us!