1.3.0 • Published 6 years ago

table-class v1.3.0

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

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.

ParamTypeDescription
widthnumberHorizontal size of the array.
heightnumberVertical size of the array.
callbackfnconstructorCallbackThis 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.

ParamTypeDescription
xnumberX index.
ynumberY index.
valueTValue to be set.

table.get(x, y) ⇒ T

Returns value at given coordinates.

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

ParamTypeDescription
xnumberX index.
ynumberY index.

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

Returns a specific row.

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

ParamTypeDescription
ynumberIndex 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.

ParamTypeDescription
xnumberIndex 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.

ParamTypeDescription
callbackfnmapCallbackThis 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.

ParamTypeDescription
callbackfnreduceCallbackThe reduce method calls this function one time for each value of the table.
initialValueUIf 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

ParamTypeDescription
callbackfnforEachCallbackFunction 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.

ParamTypeDescription
rowsArray.<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.

ParamTypeDescription
colsArray.<Array.<?U>>Table data organized by columns.

Table~constructorCallback ⇒ T

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

ParamTypeDescription
xnumberX coordinate.
ynumberY coordinate.

Table~mapCallback ⇒ U

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

ParamTypeDescription
valueTCurrent value at given coordinates.
xnumberX coordinate.
ynumberY coordinate.
tableTable.<T>Current table.

Table~reduceCallback ⇒ U

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

ParamTypeDescription
previousValueUPrevious accumulation result.
currentValueTValue at given coordinates.
currentXnumberX coordinate.
currentYnumberY coordinate.
tableTable.<T>Current table.

Table~forEachCallback : function

Kind: inner typedef of Table

ParamTypeDescription
valueTValue at given coordinates.
xnumberX coordinate.
ynumberY coordinate.
tableTable.<T>Current table.
1.3.0

6 years ago

1.2.0

6 years ago

1.1.2

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago