Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

container-dot-js

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

container-dot-js

Library for creating dynamic objects with convenient generic attributes and methods

  • 1.0.4
  • unpublished
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

ContainerJS

An experiment with the objective of bringing rational objects using a solid abstraction to provide methods and attributes that follow a fixed pattern and increase the readability and coherence of the code.

Versions

VersionBranch
developmentmain
1.0.4v1.0.4
1.0.3v1.0.3
1.0.1v1.0.1
1.0.0v1.0.0

How it works?

ContainerJS is a library that implements a new JavaScript constructor, Container, among its functionalities its main use is to isolate an object in a solid abstraction, allowing safe and coherent operations to be performed with it and keeping it in its initial type, which prevents unwanted behaviors.

A Container can also provide a lot of generic functions to handle, edit and manage the data as it was inspired by tools like Linq (from .NET) and py Linq (an implementation of Linq in Python).

Interesting use cases

Getting data selectively

A container allows recursive operations, one of those possibilities is the ability to get ordered data, such as "the first 5 items of an iterable object", "the last 3 items of an iterable object" or "the first 5 items of an iterable object skipping two objects".

Examples:

const MyContainer = Container.from([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);

//Will return the first 5 items ([1, 2, 3, 4, 5])
MyContainer.first(5);

//Will return the last 3 items ([10, 9, 8])
MyContainer.last(3);

//Will return the first 5 items skipping 3 ([4, 5, 6, 7, 8])
MyContainer.skip(3).first(5);

Unifying data management

A container is capable of dynamically detecting its type when being created, from that it allows the management of data in a unified way using generic methods. It currently supports popular JavaScript types such as Array, Object, Set and Map.

Examples:

const MyContainer = Container.from([]);

MyContainer.add(1); //Will add the item 1 to MyContainer content
const MyContainer = Container.from(new Set([]));

MyContainer.add(1); //Will add the item 1 to MyContainer content
const MyContainer = Container.from({});

MyContainer.add("a", 1); //Will add the item {a: 1} to MyContainer content
const MyContainer = Container.from(new Map());

MyContainer.add("a", 1); //Will add the item {a: 1} to MyContainer content

Installation

Via NPM:

npm install container-dot-js

Manually:

git clone https://github.com/EternalQuasar0206/container-js

Getting Started

To start using ContainerJS in a project just use the snippet:

import { Container } from "container-dot-js"

or

import { Container } from "/path/to/repo/container.js"

You can get started and learn about all the ContainerJS features here.

Keywords

FAQs

Package last updated on 02 Dec 2021

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