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

yamlx

v0.1.8

Published

YAML parser (eXtended)

Downloads

28

Readme

yamlx

YAML loader (eXtended)

forked from https://github.com/teniryte/xyaml

const yamlx = require('yamlx');

var data = yamlx.loadFile(__dirname + '/pipeline.yaml');

YAML File Example

env: ~env(HOME)
name: test
port: 8080
domain: ${name}.com
portStr: ~str(${self.port})
portNum: ~num(${self.portStr})
hasPort: ~bool(${portNum})
url: ${domain}:${port}
level1:
  port: 3000
  port1: ${port+10}
  port2: ${root.port+10}
  portRange: ${port1-10}..${port2+10}
  -export: ~export(root, export.yaml)
  level2:
    level3: test
    -merge: ~merge(items)

icons: ~import(icons)
test1: ~read(${name}1.txt)
test2: ~include(test2.json)
test3: ~read(admin.yaml)

items:
  - ${name}1
  - ${name}2
  - ${name}3

Yaml Commands

  • ${exp} - run expression. Available all keys from current level (self) and all parents levels + root
  • ~str(exp) - convert to string
  • ~num(exp) - convert to number
  • ~bool(exp) - convert to boolean
  • ~env(varName, default) - fetch Environment variable or use default value
  • ~merge(source1, source2, ...) - deep merge all sources to current level (key with merge command will be removed)
  • ~mergeOverwrite(source1, source2, ...) - alias for ~merge
  • ~mergeDiscard(source1, source2, ...) - same as merge, but NOT override exists keys
  • ~mergeAppend(source1, source2, ...) - same as merge, but also concat arrays
  • ~del(key1, key2, ...) - remove specified keys
  • ~include(filename) - read yaml/json file in include as object
  • ~read(filename) - read and insert file as string
  • ~export(key, filename.yaml) - export specified key as YAML or JSON

API

yamlx

yamlx.loadFile(filename, [opts]);

Data

Constructor

var data = new Data(data, (opts = {}));

Methods

  • Paths:
    • fullPath([name]): Get full pathname.
    • fullName([name]): Get full data's name.
  • Fork:
    • fork([name]): Fork data object.
  • Parents:
    • rootData(): Get root data object.
    • getParent([name]): Get path's parent object.
    • dataParent([name]): Get path's data parent object.
    • dataParents([name], [includeSelf = false]): Get path's data parent objects array.
  • Data:
    • getData([name]): Get plain javascript-object.
    • log([name]): Log plain object data to console.
    • toJSON([name]): Get JSON-serialized string.
  • Options:
    • options(): Get full options object.
    • option(name): Get option value.
    • option(name, val): Set option value.
  • Files:
    • getDirname(): Get data's directory name.
    • getFilename(): Get data's file name.
    • resolve([path]): Resolve path relative to data's directory name.
  • Properties:
    • def(): Get data's properties object.
    • def(name): Get property.
    • def(name, value): Set property.
    • has(name): true if data has property name.
    • keys(): Get data's properties names array.
    • del(name): Delete property name.
    • set(name, value): Set property.
    • get(name): Get property.
  • Private:
    • priv(): Get data's private properties object.
    • priv(name): Get private property value.
    • priv(name, value): Set private property value.
    • privHas(name): true if data has private property name.
    • privKeys(): Get data's private properties names array.
    • privDel(name): Delete private property name.
  • Eval:
    • expression(value): Eval expression value in data's scope (context contains properties self, root, filename, dirname and all properties of current data).
    • interpolate(value): Replace expressions like ${expression} in text value.