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

flipr-yaml

v2.0.1

Published

Flipr source to retrieve config from yaml files

Downloads

9

Readme

node-flipr-yaml

NPM

Build Status

This project is part of the flipr family.

node-flipr-yaml is a flipr source for retrieving flipr configuration data from yaml files.

node-flipr

How does it work?

The examples below show you how to create the flipr yaml source. A source by itself isn't very useful. You'll still need to give the source to flipr, so that it can use it to do awesome things. See the flipr documentation for how to use a source.

Here's the simplest example:

---
# Here's a basic YAML config file. Assume it exists at config/simple.yaml
someConfigKey:
  description: >
    This is some config key that has some value.
  value: someValue
const FliprYaml = require('flipr-yaml');
const source = new FliprYaml({
  filePath: 'config/simple.yaml',
});
source.getConfig().then(
  config => console.log(config),
  err => console.log(err),
);

Validating your yaml files

flipr-yaml has the ability to validate your yaml files. This is very useful if you're storing your yaml files alongside your app code and using a CICD pipeline to automatically deploy changes. You can create a unit test that runs flipr-yaml's config validation, thereby catching any breaking changes to the config before they are released. The validation only catches syntax errors in the config. If you provide flipr-yaml the flipr rules you use in your application, it will catch some logical errors as well, like the values of a percent rule not adding up to 100%. See here for an example.

Would you like to know more?

Methods

In most cases, you should not need to call flipr-yaml's methods directly, flipr takes care of that. However, it can be useful for testing and config validation.

  • async getConfig() - Returns yaml config as an object. The first call to this method caches the config, which can be cleared by calling the async flush() method.
  • async preload() - Loads the config into cache. Does the same thing as getConfig. It's called preload to fulfill flipr's source contract.
  • async flush() - Flushes all cached values in flipr-yaml.
  • async validateConfig(rules) - Validates the yaml files based on flipr's configuration syntax. See flipr-validation for more information.

Constructor Options

  • filePath - required - string, array - The yaml config file path(s) relative to the process's cwd. Supports glob patterns based on minimatch patterns.
  • duplicateKeysOverride - bool - If true, duplicate keys in a multi-file scenario will be overridden by whichever is read last. Default is false, which results in an error thrown.