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

@nuskin/ns-util

v4.6.0

Published

## Contentstack Contentstack GraphQL calls.

Downloads

10,197

Readme

ns-util

Kindly add a basic usage here after you've created a utility.

Contentstack

Contentstack GraphQL calls.

import { contentstackService, util } from '@nuskin/ns-util';

/**
 * getAEMConfig fetches the market config from contentstack.
 * It will return null if an error occurs.
 *
 * @output null | {
 *   aws_url: "https://aws.test-url.com",
 *   checkout_client_id: "client-id",
 *   checkout_client_secret: "client-secret"
 * }
 */
const aemConfig = await contentstackService.getAEMConfig();

/**
 * getEquinoxMarkets will get the list of Equinox-enabled markets from contentstack.
 *
 * @output null | [
 *   {
 *     country_code: "CA",
 *     market_name: "Canada",
 *     store_id: "407"
 *   },
 *   {
 *     country_code: "US",
 *     market_name: "United States",
 *     store_id: "406"
 *   }
 * ]
 */
const markets = await contentstackService.getEquinoxMarkets();

/**
 * isMarketEnabled checks is the given market is in the list
 * of equinox-enabled markets. It will return the market if found.
 * Otherwise, returns null.
 *
 * @output null | {
 *   country_code: "CA",
 *   market_name: "Canada",
 *   store_id: "407"
 * }
 */
const market = await contentstackService.isMarketEnabled(util.countryCode);

Equinox Local Storage Usage

Equinox Local Storage utilities. It is used in the following projects:

Note: deprecated functions will be removed in the next major release.

import { equinoxLocalStorage } from '@nuskin/ns-util';

/**
 * getEnabledMarkets gets the list of enabled markets.
 * Returns an object of MarketList if found. Otherwise,
 * it will return null.
 *
 * @deprecated Use contentstack.getEquinoxMarkets
 * @output null | {
 *   ca: { name: 'Canada', storeID: '423' },
 *   us: { name: 'United States', storeID: '422' }
 * }
 */
const markets = equinoxLocalStorage.getEnabledMarkets();

/**
 * getMarket gets a specific market from the list of equinox-enabled markets.
 * Returns an object of Market if found.
 *
 * @deprecated Use contentstack.isMarketEnabled
 * @output { name: 'United States', storeID: '422' }
 */
const market = equinoxLocalStorage.getMarket('us');

/**
 * isEquinoxEnabled checks if the `isEquinoxEnabled` is in localstorage
 * and the value is set to true.
 *
 * @output true | false
 */
const isEquinoxEnabled = equinoxLocalStorage.isEquinoxEnabled();

/**
 * isMarketEnabled checks if the argument is in the list of enabled markets
 * AND `isEquinoxEnabled` is set to true in localstorage.
 *
 * @deprecated Use contentstack.isMarketEnabled
 * @output true | false
 */
const isMarketEnabled = equinoxLocalStorage.isMarketEnabled('us');

/**
 * setEnabledMarkets saves the value in local storage.
 * Returns a boolean that indicates whether the task is successful.
 *
 * @deprecated There is no need to set this locally
 * @output true | false
 */
const isEnabledMarketsSaved = equinoxLocalStorage.setEnabledMarkets({
    ca: { name: 'Canada', storeID: '423' },
    us: { name: 'United States', storeID: '422' }
});

Tags

#contentstack #equinox #graphql #localstorage