1.0.3 • Published 3 years ago

overloadfig v1.0.3

Weekly downloads
13
License
ISC
Repository
github
Last release
3 years ago

Overloadfig 🤯

Config Descriptors.

  • Easy to use
  • Loose Goosey
  • Json

Examples

Don't believe me? take a look at this stuff ripped out of example.js:

// Example overloadfig
const exampleSpec = {
    "action": {
        "string": (val) => {
            console.log("hello " + val);
        },
        "number": (val) => {
            console.log("number: " + val);
        },
        "object": {
            "http": (val) => {
                console.log("making a http get! (not really obviously)" );
                return "abc"; // Could return the actual value here
            },
        },
    },
    "msg": { // Note don't have to specify that it's an object
        "name": (name) => {
            console.log(`hello ${name}!`);
            return `hello ${name}!`;
        }
    },
}

// Basic callbacks on values
loadConfig(exampleSpec, {
    "action": "to new overloadfig user!",
    "msg": {
        "name": "root"
    }
});
// Outputs ->
//     hello to new overloadfig user!
//     hello root!



// Return values
// Also all keys are optional, best effort approach with minimal erroring
console.log(loadConfig(exampleSpec, {
    "action": {
        "http": "asdf"
    },
}));
// Outputs ->
//     making a http get! (not really obviously)
//     { action: { http: 'abc' } }

FUTURE WORK

  • Strict mode
  • Typescript
1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago