Socket
Socket
Sign inDemoInstall

figgy-pudding

Package Overview
Dependencies
0
Maintainers
2
Versions
14
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.0.0 to 3.1.0

10

CHANGELOG.md

@@ -5,2 +5,12 @@ # Change Log

<a name="3.1.0"></a>
# [3.1.0](https://github.com/zkat/figgy-pudding/compare/v3.0.0...v3.1.0) (2018-04-08)
### Features
* **opts:** allow direct option fetching without .get() ([ca77aad](https://github.com/zkat/figgy-pudding/commit/ca77aad))
<a name="3.0.0"></a>

@@ -7,0 +17,0 @@ # [3.0.0](https://github.com/zkat/figgy-pudding/compare/v2.0.1...v3.0.0) (2018-04-06)

54

index.js

@@ -5,8 +5,8 @@ 'use strict'

constructor (specs, opts, providers) {
this.specs = specs || {}
this.opts = opts || (() => false)
this.providers = reverse((providers || []).filter(
this.__specs = specs || {}
this.__opts = opts || (() => false)
this.__providers = reverse((providers || []).filter(
x => x != null && typeof x === 'object'
))
this.isFiggyPudding = true
this.__isFiggyPudding = true
}

@@ -18,5 +18,5 @@ get (key) {

return new FiggyPudding(
this.specs,
this.opts,
reverse(this.providers).concat(moreConfig)
this.__specs,
this.__opts,
reverse(this.__providers).concat(moreConfig)
)

@@ -27,8 +27,8 @@ }

function pudGet (pud, key, validate) {
let spec = pud.specs[key]
let spec = pud.__specs[key]
if (typeof spec === 'string') {
key = spec
spec = pud.specs[key]
spec = pud.__specs[key]
}
if (validate && !spec && (!pud.opts.other || !pud.opts.other(key))) {
if (validate && !spec && (!pud.__opts.other || !pud.__opts.other(key))) {
throw new Error(`invalid config key requested: ${key}`)

@@ -38,4 +38,4 @@ } else {

let ret
for (let p of pud.providers) {
if (p.isFiggyPudding) {
for (let p of pud.__providers) {
if (p.__isFiggyPudding) {
ret = pudGet(p, key, false)

@@ -63,10 +63,36 @@ } else if (typeof p.get === 'function') {

const proxyHandler = {
has (obj, prop) {
return pudGet(obj, prop, false) !== undefined
},
get (obj, prop) {
if (
prop === 'concat' ||
prop === 'get' ||
prop.slice(0, 2) === '__'
) {
return obj[prop]
}
return obj.get(prop)
},
set (obj, prop, value) {
if (prop.slice(0, 2) === '__') {
obj[prop] = value
} else {
throw new Error('figgyPudding options cannot be modified. Use .concat() instead.')
}
},
delete () {
throw new Error('figgyPudding options cannot be deleted. Use .concat() and shadow them instead.')
}
}
module.exports = figgyPudding
function figgyPudding (specs, opts) {
function factory (...providers) {
return new FiggyPudding(
return new Proxy(new FiggyPudding(
specs,
opts,
providers
)
), proxyHandler)
}

@@ -73,0 +99,0 @@ return factory

{
"name": "figgy-pudding",
"version": "3.0.0",
"version": "3.1.0",
"description": "Delicious, festive, cascading config/opts definitions",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc