GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - sammarks/object-reference: Resolve self-referencing objects in NodeJS.

BranchesTags
Open more actions menu

Latest commit

 

History

22 Commits
22 Commits

Folders and files

NameName
Last commit message
Last commit date
.circleci
.circleci
 
 
src
src
 
 
.babelrc
.babelrc
 
 
.gitignore
.gitignore
 
 
CHANGELOG.md
CHANGELOG.md
 
 
LICENSE.txt
LICENSE.txt
 
 
README.md
README.md
 
 
package-lock.json
package-lock.json
 
 
package.json
package.json
 
 
tsconfig.json
tsconfig.json
 
 
tslint.json
tslint.json
 
 

Repository files navigation

CircleCI NPM NPM License Issues

Object reference allows you to build objects that reference themselves.

Get Started

npm install --save object-reference
const resolve = require('object-reference')

const theme = {
  colors: {
    black: '#424242',
    white: '#FFF'
  },
  background: '$.colors.white',
  foreground: '$.colors.black',
  margins: {
    page: '30px'
  }
}

const processedTheme = resolve(theme)
console.log(processedTheme)

// {
//   colors: {
//     black: '#424242',
//     white: '#FFF'
//   },
//   background: '#FFF',
//   foreground: '#424242',
//   margins: {
//     page: '30px'
//   }
// }

Features

  • Uses _.get() from Lodash under the hood.
  • Detects circular references and throws a detailed error message explaining the situation.
  • Resolves nested references (references that reference other references).

Why use this?

I've found the perfect use-case to be defining configuration in a single object, with common variables like colors or sizes at the top of the configuration file, and then specific overrides underneath that reference the variables by default.

This allows the user to have the simplicity of changing a few variables at the top of the document to make a sweeping impact, or getting fine-grained and changing small values toward the bottom of the document.

About

Resolve self-referencing objects in NodeJS.

Topics

configconfigurationjavascriptnpm-packageobjectsreferences

Resources

Readme
MIT license
Activity

Stars

0 stars

Watchers

1 watching

Forks

0 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.