GithubHelp home page GithubHelp logo

victoriaquasar / container-js Goto Github PK

View Code? Open in Web Editor NEW
3.0 1.0 0.0 132 KB

Library for creating dynamic objects with convenient generic attributes and methods

License: MIT License

JavaScript 100.00%
library objects operations abstractions arrays dictionaries javascript-library

container-js's Introduction

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

Info: DO NOT use the development version, use a branch stable version.

Version Branch
development main
1.0.4 v1.0.4
1.0.3 v1.0.3
1.0.1 v1.0.1
1.0.0 v1.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.

container-js's People

Contributors

scarletquasar avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

container-js's Issues

events being duplicated due to nested functions (main branch)

This is happening due to nested function calls inside functions, the current path to solve this is add a silent attributes getter (maybe setter) for event-free operations

Target: add/removeEventListener effects
Reproduce: execute npm run test with deno installed

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.