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

zim-gamshooks

v0.8.1

Published

Hooks for simplifying usage with GAMS.

Downloads

11

Readme

ZIM GAMS Hooks

Short Description

Hooks for simplifying usage with GAMS.

Included hooks / short

GAMS data exchange

  1. useJsGlobal -> handles data exchange using global js variables
  2. useDatastream -> handles data exchange via requesting against a datastream of GAMS digital objects.
  3. useQueryObject -> handles construction of gams query-object sparql urls.

GAMS related client side calculations

  1. useDrilldown -> Client side calculation of faceted drilldown. (= Counting assigned tags)
  2. usePagination -> client side pagination represanting pages / chunks as tuples.

Typings

  • import from main entry point "zim-gamshooks"

Demos & Examples

Handling Gams data exchange


const GamsHooksDemo: React.FC = () => {

  // hook returns data and gui prop of global variable.
  // define type of returned property via ts
  const { data, gui }: {data: string, gui: string} = useJsGlobal("demo_conf");

  // use datastream works the same (awaits global json at a gams-object)
  // empty will request current pid object
  const dsData = useDatastream();
  
  // configure via params
  const dsData2 = useDatastream("context:fercan");
  const dsData3 = useDatastream("context:fercan", "MY_DATASTREAM_NAME");
  //       

  // example for requesting different datastreams depending on object.
  // assign datastream name as second param - do conditional logic to provide name.
  const example = useDatastream(null, window.location.href.includes("mode_main") ? "MAIN_DATASTREAM" : "SECONDARY_DATASTREAM");
  // use returned values.


  // example usage of useQueryObject hook
  const { buildQuery, toggleSparqlParam } = useQueryObject("context:derla");


  return (
    <div>
      {data ? <p>Data applied!</p> : null}
      <p>{data}</p>
    </div>
  )
};

export default GamsHooksDemo;

GAMS related client side ops

useDrilldown


// inside React component

// use hook 
const { drillDown, toggleTag, tagCounts } = gamsHooks.useDrilldown(props.drillDown.data);


Utility functions - gamsUtils

  • collection of utility methods used for gams development.

Contribute

Useful Resources

  • https://medium.com/@jchiam/publishing-a-typescript-react-component-to-npm-d3cc15b8d0a2
  • https://itnext.io/step-by-step-building-and-publishing-an-npm-typescript-package-44fe7164964c

Create react app and useful stuff:

  • https://github.com/wmonk/create-react-app-typescript/blob/master/template/README.md#publishing-components-to-npm

Important Scripts

# locally build publishable lib folder
# this folder will be published by npm publish later on
# make sure that in tsconfig.json -> noEmit is set to false!
npm run npm:build

# login to npm before
npm login

# apply new version
npm version x.y.z

# then publish to npmjs 
npm publish