🚨 Latest Research:Tanstack npm Packages Compromised in Ongoing Mini Shai-Hulud Supply-Chain Attack.Learn More →
Socket
Book a DemoSign in
Socket

@okiba/pool-system

Package Overview
Dependencies
Maintainers
3
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@okiba/pool-system

Class to manage dinamically a pool of system

latest
Source
npmnpm
Version
1.0.25
Version published
Maintainers
3
Created
Source

Okiba / PoolSystem

Manages a dinamically grown pool of DOM Elements import PoolSystem from '@okiba/pool-system'

__

const container = document.querySelector('#container')

function createEl(){
 return document.createElement('img');
}

const pool = new PoolSystem(container, createEl)

Installation

npm i --save @okiba/pool-system

Or import it directly in the browser

<script type="module" src="https://unpkg.com/@okiba/pool-system/index.js"></script>

Usage

import PoolSystem from '@okiba/pool-system'

Untranspiled code 🛑

Okiba Core packages are not transpiled, so don't forget to transpile them with your favourite bundler. For example, using Babel with Webpack, you should prevent imports from okiba to be excluded from transpilation, like follows:

{
  test: /\.js$/,
  exclude: /node_modules\/(?!(@okiba)\/).*/,
  use: {
    loader: 'babel-loader',
    options: {
      presets: ['@babel/preset-env']
    }
  }
}

constructor(parent, createEl)

Arguments

+ parent: Object

DOM Element used as container for all pool elements.

+ createEl: function

Function that creates an istance the element you want to add to the pool.

ensure(size)

Makes sure the pool can host a minimum number of elements, grows it if that's not the case.

Arguments

+ size: Number

Minimum pool size to ensure.

get()

Hands a free element from the pool. If there isn't one, it automatically grows the pool's. This provides dynamic sizing which ensures

Returns

Element A free DOM Element

free(Element)

Marks an element as elegible for reutilization, and pushes it into the pool

Arguments

+ Element: Element

to mark as free

destroy()

Nulls all references to DOM Elements

FAQs

Package last updated on 26 May 2020

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