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

dict-of-dicts-to-ini-lines-pmb

v1.0.3

Published

Translate your dictionary object of dictionary objects to an array of strings that could be lines of a .ini file.

Downloads

6

Readme

dict-of-dicts-to-ini-lines-pmb

Translate your dictionary object of dictionary objects to an array of strings that could be lines of a .ini file.

API

This module exports one function that holds some methods:

dod2ini(sectionsDict[, opt])

Where sectionsDict is an object that maps section titles to dictionaries that will be used as the key-value-pairs.

  • Array values are processed by repeating the key for each value.
    • But only if they are encountered directly in the 2nd level dictionary.
  • Pairs with undefined as the value are skipped unless configured otherwise.

opt is an optional options object that supports these keys:

  • sort: Whether and how to sort sections (if sectSort is false-y) and/or keys (if keySort is false-y). This does not affect the order of multiple values for one key. If true, sort with default algorithm. Any another truthy value is assumed to be, and used as, a custom comparison function.
  • sectSort: If truthy, override sort with respect to sections.
  • keySort: If truthy, override sort with respect to keys.
  • eol: Append this string to each line. Defaults to empty string.
  • pairSep: Put this string between key and value. Defaults to '='.
  • pairInd: Put this string before the key. Defaults to the empty string.
  • translateValues: If truthy, try to translate values. This can be used to not suppress undefined values (by translating them to e.g. the empty string), and to suppress unwanted values (by translating them to undefined).
    • If set to a function, it will be invoked with arguments (val, key, sect).
    • If set to an object or Array, translate empty string values and non-string, values by property lookup.
      • Objects are stringified for this lookup, and thus can masquerade as other values. Just avoid using objects or nested Arrays as values.
      • A result of undefined means "keep the original value", and null means "skip this pair".
  • skipSectionName: If string, omit section header line for the section with this name. Can also be false to add header lines for all sections. Default: '\n'

dod2ini.cfg(opt)

return function custom(sectionsDict) { return dod2ini(sectionsDict, opt); };

Usage

see test.usage.js.

Known issues

  • Needs more/better tests and docs.

 

License

ISC