New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ezzy-config-setup

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ezzy-config-setup

A complex function configuration

  • 3.1.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

ezzy-config-setup

Greenkeeper badge Build Status Coverage Status

Changes a number of arguments into a readable configuration object. The arguments can have different organization, position, type, etc, which turn into different properties.

 // Example usage by simply passing arguments
 configSetup(arguments, ["method:string"], ["config:object", "callback"]);
 // Example usage with a default configuration
 configSetup(
   defaultConfig,
   arguments,
   ["method:string"],
   ["config:object", "callback"]
 );

Example Implementation

 
 function MyClass() {
   this.config = configSetup(
     
     // default configuration properties
     {
       booleanProp: true,
       arrayProp: [ 1, 2, 3 ],
       objectProp: { a:null, b:null }
     },

     // arguments passed to the constructor
     arguments,

     // if there's only 1 object argument, it extends 'this' object
     ['this:object'],

     // or it can look for type and override specific properties
     ['arrayProp:array'],
     ['booleanProp:boolean'],

     // with 2 arguments, it overrides different properties
     // based on type
     ['booleanProp:boolean', 'arrayProp:array'],
     ['arrayProp:boolean', 'objectProp:object'],
     ['objectProp:object', 'arrayProp:array'],

     // or has the ability to distinguish between positional arguments
     ['booleanProp:boolean', 'arrayProp:array', 'objectProp:object'],
     ['objectProp:object', 'booleanProp:boolean', 'arrayProp:array'],
     ['arrayProp:array', 'objectProp:object', 'booleanProp:boolean']

   );

 // Therefore...

 // single boolean argument
 var myClass1 = new MyClass(false);
 myClass1.config.booleanProp = false;
 myClass1.config.arrayProp = [1,2,3];

 // single array argument
 var myClass2 = new MyClass([]);
 myClass2.config.booleanProp = true;
 myClass2.config.arrayProp = [];

 // multiple positioned arguments
 var myClass3 = new MyClass({}, false, []);
 myClass3.config.booleanProp = false;
 myClass3.config.arrayProp = [];
 myClass3.config.objectProp = {};

 // and now shuffled around
 var myClass4 = new MyClass([], {}, false);
 myClass4.config.booleanProp = false;
 myClass4.config.arrayProp = [];
 myClass4.config.objectProp = {};

 // Cool, huh?!
 // Now we have achieved what Java already had for centuries.

FAQs

Package last updated on 27 Sep 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc