Socket
Socket
Sign inDemoInstall

inra-server-container

Package Overview
Dependencies
0
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    inra-server-container

Container is a component that implements Service Location of services and it's itself a container for them.


Version published
Maintainers
1
Created

Readme

Source

inra-server-container

npm Dependency Status

The container is a component that implements Service Location of services and it's itself a container for them. Since the server is highly decoupled, it is essential to integrate different components. The developer can also use this component to inject dependencies and manage global instances of the different classes used in the application.

Basically, this component implements the "Inversion of Control" pattern: the objects do not receive their dependencies using setters or constructors, but requesting something similar to "service dependency injector". This reduces the overall complexity since there is only one way to get the required dependencies within a component. Additionally, this pattern increases testability in the code, thus making it less prone to errors.

Note: full documentation with more examples is published on our Wiki. Please, refer to our Wiki for installation details and API references.

Installation

$ npm install --save inra-server-container

API

const container = new Container();

.set(key, value)

Adds or updates an element with a specified key and value to a Container instance. Returns the Container itself.

Note: Any value (both objects and primitive values) may be used as either a key or a value in the default Container. This is not necessarly the case for other containers that implement ContainerInterface.

Example:

container.set("foo", …);
container.set("bar", …);

.get(key [, defaultValue])

Returns the value associated to specified key, or defaultValue if there is none.

Example:

container.get("foo");    //> …
container.get("zoo", 1); //> 1

.has(key)

Returns a boolean asserting whether an element with the specified key exists in a Container instance or not.

Example:

container.has("foo"); //> true
container.has("zoo"); //> false

.delete(key)

Removes the value associated to specified key and returns true if it was deleted successfully, or false otherwise.

Example:

container.delete("foo"); //> true
container.delete("zoo"); //> false

.clear()

Removes all key/value pairs from a Container instance.

Example:

container.clear();

.size

Returns the number of key/value pairs in a Container instance.

Example:

container.set("foo", …);
container.set("bar", …);
container.set("zoo", …);

container.size; //> 3

Contributing

Bug reporting

Github Open Issues Github Closed Issues Github Pull Requests

We want contributing to Inra Server to be fun, enjoyable, and educational for anyone, and everyone. Changes and improvements are more than welcome! Feel free to fork and open a pull request. If you have found any issues, please report them here - they are being tracked on GitHub Issues.

Development

We have prepared multiple commands to help you develop inra-server-container on your own. Don't forget to install all Node.js dependencies from npm. You will need a local copy of Node.js installed on your machine.

$ npm install
Usage
$ npm run <command>
List of commands
CommandDescription
buildBuilds inra-server-container
watchRe-builds inra-server-container on changes
cleanDeletes builds ands cache
lintFixes Lint errors
flowChecks Flow errors
testChecks Flow errors and runs tests

FAQs

Last updated on 15 May 2018

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc