npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

table-class

v1.3.0

Published

Utility class for easier handling of two-dimensional arrays.

Downloads

7

Readme

Table

Represents a two-dimensional array of data.

Kind: global class
Template: T Type of data that will be stored by this table.

new Table(width, height, [callbackfn])

Creates an instance of Table.

| Param | Type | Description | | --- | --- | --- | | width | number | Horizontal size of the array. | | height | number | Vertical size of the array. | | [callbackfn] | constructorCallback | This function is used to populate table during initialization. |

table.width : number

Horizontal size of the array

Kind: instance property of Table
Read only: true

table.height : number

Vertical size of the array.

Kind: instance property of Table
Read only: true

table.rows : Array.<Array.<?T>>

Table data organized by rows.

Kind: instance property of Table
Read only: true

table.cols : Array.<Array.<?T>>

Table data organized by columns.

Kind: instance property of Table
Read only: true

table.set(x, y, value) ⇒ Table.<T>

Sets a value at given coordinates.

If one of the coordinates equals null, value will be set for the whole row/column.

Kind: instance method of Table
Returns: Table.<T> - This table.

| Param | Type | Description | | --- | --- | --- | | x | number | X index. | | y | number | Y index. | | value | T | Value to be set. |

table.get(x, y) ⇒ T

Returns value at given coordinates.

Kind: instance method of Table
Returns: T - Value at given coordinates.

| Param | Type | Description | | --- | --- | --- | | x | number | X index. | | y | number | Y index. |

table.row(y) ⇒ Array.<?T>

Returns a specific row.

Kind: instance method of Table
Returns: Array.<?T> - Row of data.

| Param | Type | Description | | --- | --- | --- | | y | number | Index of a row to be returned. |

table.col(x) ⇒ Array.<?T>

Returns a specific column.

Kind: instance method of Table
Returns: Array.<?T> - Column of data.

| Param | Type | Description | | --- | --- | --- | | x | number | Index of a column to be returned. |

table.map(callbackfn) ⇒ Table.<U>

Creates new table using this table values.

Kind: instance method of Table
Returns: Table.<U> - New table.
Template: U Type of data that will be stored by new table.

| Param | Type | Description | | --- | --- | --- | | callbackfn | mapCallback | This function is used to populate new table using current table values. |

table.reduce(callbackfn, initialValue) ⇒ U

Calls the specified callback function for all table values and returns accumulation result.

Kind: instance method of Table
Returns: U - Accumulation result.
Template: U Type of accumulation result.

| Param | Type | Description | | --- | --- | --- | | callbackfn | reduceCallback | The reduce method calls this function one time for each value of the table. | | initialValue | U | If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of a table value. |

table.forEach(callbackfn, [thisArg])

Performs the specified action for each element in a table.

Kind: instance method of Table

| Param | Type | Description | | --- | --- | --- | | callbackfn | forEachCallback | Function called one time for each element in the table. | | [thisArg] | * | An object to which the this keyword can refer in the callbackfn function. |

table.toString() ⇒ string

Returns a string representation of this table.

Kind: instance method of Table
Returns: string - String representation of table.

table.cw() ⇒ Table.<T>

Rotates table clockwise.

Kind: instance method of Table
Returns: Table.<T> - New table.

table.ccw() ⇒ Table.<T>

Rotates table counterclockwise.

Kind: instance method of Table
Returns: Table.<T> - New table.

table.flipX() ⇒ Table.<T>

Flips table horizontally.

Kind: instance method of Table
Returns: Table.<T> - New table.

table.flipY() ⇒ Table.<T>

Flips table vertically.

Kind: instance method of Table
Returns: Table.<T> - New table.

Table.fromRows(rows) ⇒ Table.<U>

Returns a new table populated with values from given array.

It handles variable rows length by setting null for missing values.

Kind: static method of Table
Returns: Table.<U> - New table with given values.
Template: U Type of data that will be stored by new table.

| Param | Type | Description | | --- | --- | --- | | rows | Array.<Array.<?U>> | Table data organized by rows. |

Table.fromCols(cols) ⇒ Table.<U>

Returns a new table populated with values from given array.

It handles variable columns length by setting null for missing values.

Kind: static method of Table
Returns: Table.<U> - New table with given values.
Template: U Type of data that will be stored by new table.

| Param | Type | Description | | --- | --- | --- | | cols | Array.<Array.<?U>> | Table data organized by columns. |

Table~constructorCallback ⇒ T

Kind: inner typedef of Table
Returns: T - Value for given coordinates.

| Param | Type | Description | | --- | --- | --- | | x | number | X coordinate. | | y | number | Y coordinate. |

Table~mapCallback ⇒ U

Kind: inner typedef of Table
Returns: U - New value for given coordinates.

| Param | Type | Description | | --- | --- | --- | | value | T | Current value at given coordinates. | | x | number | X coordinate. | | y | number | Y coordinate. | | table | Table.<T> | Current table. |

Table~reduceCallback ⇒ U

Kind: inner typedef of Table
Returns: U - Accumulation result.

| Param | Type | Description | | --- | --- | --- | | previousValue | U | Previous accumulation result. | | currentValue | T | Value at given coordinates. | | currentX | number | X coordinate. | | currentY | number | Y coordinate. | | table | Table.<T> | Current table. |

Table~forEachCallback : function

Kind: inner typedef of Table

| Param | Type | Description | | --- | --- | --- | | value | T | Value at given coordinates. | | x | number | X coordinate. | | y | number | Y coordinate. | | table | Table.<T> | Current table. |