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

@dimerapp/utils

v2.0.1

Published

Handy utilities to keep all other repos DRY and consistent

Downloads

24

Readme

DimerApp utils

Handy utilities to keep all other repos DRY and consistent

The utils library provides a handful of methods to be used across multiple dimer repos.

Installation

npm i @dimerapp/utils

# Yarn
yarn add @dimerapp/utils

Usage

const utils = require('@dimerapp/utils')

const basePath = __dirname
const distPath = 'dist' // optional

const paths = utils.paths(basePath, distPath)
const permalink = utils.permalink
const validator = utils.validator

nodeToString(node)

Convert Dimer content JSON node to a plain string

const { nodeToString } = require('@dimerapp/utils')
nodeToString(node)

Classes

Functions

Paths

Kind: global class

new Paths(basePath, [distPath])

Returns paths to certain directories, required by dimer

| Param | Type | Default | | --- | --- | --- | | basePath | String | | | [distPath] | String | 'dist' |

Permalinks

Kind: global class

new Permalinks()

Generate, normalize and validate permalinks

Validator

Kind: global class

new Validator()

Exposes validation methods to validate different parts of the user input.

configFile() ⇒ String

Returns path to the config file

Kind: global function

docsPath(versionRelativePath) ⇒ String

Returns path for a given version inside the docs folder

Kind: global function

| Param | Type | | --- | --- | | versionRelativePath | String |

distPath() ⇒ String

Returns path to the dist folder

Kind: global function

apiPath() ⇒ String

Returns path to the API folder

Kind: global function

assetsPath() ⇒ String

Returns path to the assets directory

Kind: global function

zonePath(zoneSlug) ⇒ String

Returns path to a given zone directory inside the api folder

Kind: global function

| Param | Type | | --- | --- | | zoneSlug | String |

versionPath(zoneSlug, versioNo) ⇒ String

Returns path to a given version inside the api folder

Kind: global function

| Param | Type | | --- | --- | | zoneSlug | String | | versioNo | String |

metaFile() ⇒ String

Returns path to the meta file inside the api folder

Kind: global function

searchIndexFile(zoneSlug, versionNo) ⇒ String

Returns path to the search index file inside the api folder

Kind: global function

| Param | Type | | --- | --- | | zoneSlug | String | | versionNo | String |

docPath(zoneSlug, versionNo, jsonPath) ⇒ String

Returns path to the doc json file

Kind: global function

| Param | Type | | --- | --- | | zoneSlug | String | | versionNo | String | | jsonPath | String |

makeJsonPath(filePath) ⇒ String

Makes the json path from the doc file path. Also it makes sure to keep the slashes consistent for deployment on unix systems

Kind: global function

| Param | Type | | --- | --- | | filePath | String |

generateFromFileName(fileName) ⇒ String

Generates the permalink from the base name of a given file

Kind: global function

| Param | Type | | --- | --- | | fileName | String |

normalize(permalink) ⇒ String

Normalize permalink by removing slashes around it. Must be used when matching two permalinks

Kind: global function

| Param | Type | | --- | --- | | permalink | String |

validate(permalink) ⇒ void

Validate permalink to ensure the value is URL friendly

Kind: global function

| Param | Type | | --- | --- | | permalink | String |

isSame(lhs, rhs) ⇒ Boolean

Returns a boolean telling if 2 permalinks are same. They will be normalized before the check

Kind: global function

| Param | Type | | --- | --- | | lhs | String | | rhs | String |

validateZoneSlug(slug) ⇒ void

Validates the zone slug to make sure it's URL and folder name friendly

Kind: global function
Throws:

  • Error If slug has unallowed chars

| Param | Type | | --- | --- | | slug | String |

validateVersionNumber(no) ⇒ void

Validates the version number to make sure it's URL and folder name friendly

Kind: global function
Throws:

  • Error If version no has unallowed chars

| Param | Type | | --- | --- | | no | String |

Change log

The change log can be found in the CHANGELOG.md file.

Contributing

Everyone is welcome to contribute. Please take a moment to review the contributing guidelines.

Authors & License

thetutlage and contributors.

MIT License, see the included MIT file.