{"id":19152393,"url":"https://github.com/neooblaster/tablejs","last_synced_at":"2026-01-30T10:18:36.386Z","repository":{"id":57129801,"uuid":"385407491","full_name":"neooblaster/TableJs","owner":"neooblaster","description":"An enhanced Array with extra feature to works as 2D Table","archived":false,"fork":false,"pushed_at":"2024-12-03T23:38:12.000Z","size":87,"stargazers_count":0,"open_issues_count":2,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-02T08:08:42.114Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/neooblaster.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-07-12T23:09:17.000Z","updated_at":"2024-12-03T23:38:16.000Z","dependencies_parsed_at":"2024-12-22T09:33:50.486Z","dependency_job_id":"1fb06332-1cf5-4083-bf8b-bba4c5930482","html_url":"https://github.com/neooblaster/TableJs","commit_stats":{"total_commits":41,"total_committers":1,"mean_commits":41.0,"dds":0.0,"last_synced_commit":"73b11e4605dbd661f3cb0e982f688698503367ed"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neooblaster%2FTableJs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neooblaster%2FTableJs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neooblaster%2FTableJs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/neooblaster%2FTableJs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/neooblaster","download_url":"https://codeload.github.com/neooblaster/TableJs/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":232381487,"owners_count":18514726,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-09T08:17:38.440Z","updated_at":"2026-01-30T10:18:36.333Z","avatar_url":"https://github.com/neooblaster.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# TableJs\n\n\u003e An enhanced Array with extra features to work as 2D Table.\n\n\u003e The library is currently in DEV and README.md as well.\n\u003e You can use it for development and tests (for feedback).\n\u003e Main features are available.\n\u003e Version v1.0.0 will be released when\n\u003e coverage test will be done.\n\n``TableJs`` is a little library to create a **2D Array** (Rows with Cells)\nfrom an ``Array of Array`` or `Array of Object`\nto simplify data selection. The strength of this library is the instantiated\n``TableJs`` is a standard `Array` with enhanced features.\nThat means all your knowledge regarding ``Array`` can be applied for\nthis object. You have to keep in mind you are working with a 2D Array.\n\nIt can be also used in for Website using the following CDN :\n\n````html\n\u003c!-- Do not use \"Latest\" in production --\u003e\n\u003cscript type=\"text/javascript\" src=\"https://cdn.jsdelivr.net/gh/neooblaster/TableJs@main/releases/latest.min.js\"\u003e\u003c/script\u003e\n````\n\n````html\n\u003c!-- Use a specified version in production --\u003e\n\u003cscript type=\"text/javascript\" src=\"https://cdn.jsdelivr.net/gh/neooblaster/TableJs@main/releases/v0.1.x.min.js\"\u003e\u003c/script\u003e\n````\n\n\n## Summary\n\n[](BeginSummary)\n* [Summary](#summary)\n* [Getting Started](#getting-started)\n    * [Initializing a new ``TableJs``](#initializing-a-new-tablejs)\n    * [Get distinct values](#get-distinct-values)\n    * [Get rows](#get-rows)\n    * [Get field value of row](#get-field-value-of-row)\n    * [Appending new rows](#appending-new-rows)\n    * [Setting (Updating) field value of one row](#setting-updating-field-value-of-one-row)\n    * [Setting (Updating) field value of result of rows](#setting-updating-field-value-of-result-of-rows)\n    * [Delete rows from the table](#delete-rows-from-the-table)\n    * [Make a copy of table](#make-a-copy-of-table)\n* [Detailed documentation](#detailed-documentation)\n    * [Minimal Instantiation](#minimal-instantiation)\n    * [Managing fields](#managing-fields)\n        * [Method ``set``](#method-set)\n        * [Method ``add``](#method-add)\n        * [Method ``get``](#method-get)\n    * [Managing keys](#managing-keys)\n        * [Method ``set``](#method-set)\n        * [Method ``add``](#method-add)\n        * [Method ``get``](#method-get)\n    * [Managing Data](#managing-data)\n        * [Method ``set``](#method-set)\n        * [Method ``add`` (Alias `append`)](#method-add-alias-append)\n        * [Method ``get``](#method-get)\n        * [Method ``getRow``](#method-getrow)\n    * [Dynamic Methods](#dynamic-methods)\n        * [Method ``MyField()`` on the Array](#method-myfield-on-the-array)\n        * [Method ``MyField()`` on a row of the Array](#method-myfield-on-a-row-of-the-array)\n    * [Extra method](#extra-method)\n        * [Method ``setDeprecated``](#method-setdeprecated)\n        * [Method ``deleteRow``](#method-deleterow)\n[](EndSummary)\n\n\n\n## Getting Started\n\nYou can confer to file ``demo.js`` to retrieve back / execute the\n**Getting Started** documentation.\n\n\n### Initializing a new ``TableJs``\n\nPlease consider the following table data :\n\n| Brand |    Camera    | Date |   Format   |      Purpose      |\n|:-----:|:------------:|:----:|:----------:|:-----------------:|\n| Nikon |      D3      | 2007 | Full Frame |   Professional    |\n| Nikon |     D750     | 2014 | Full Frame |      Action       |\n| Nikon |     D800     | 2011 | Full Frame | Semi-Professional |\n| Nikon |    D810A     | 2015 | Full Frame |       Astro       |\n| Nikon |    D7100     | 2013 |   APS-C    |      Expert       |\n| Nikon |      D6      | 2020 | Full Frame |   Professional    |\n| Canon | 1Ds Mark III | 2007 | Full Frame |   Professional    |\n| Canon |  5D Mark II  | 2008 | Full Frame | Semi-Professional |\n| Canon |     60Da     | 2012 |   APS-C    |       Astro       |\n| Canon |     250D     | 2019 |   APS-C    |      Compact      |\n\nTo create a new ``TableJs`` you can instantiate it step by step\u003csup style=\"color: red\"\u003e_*_\u003c/sup\u003e \nwhen the content is full dynamic or in one shot like this :\n\n\u003csup style=\"color: red\"\u003e_*_\u003c/sup\u003e See Detailed Documentation\n\n````js\nlet cameras = new TableJs(\n    // List of Fields (At least one required)\n    ['Brand', 'Camera', 'Date', 'Format', 'Purpose'],\n    \n    // Indicating which fields compose the key\n    // → Optional, but at least empty Array must be passed\n    ['Camera', 'Brand'],\n\n    // Table Data\n    [\n        [ 'Nikon', 'D3', '2007', 'Full Frame', 'Professional' ],\n        [ 'Nikon', 'D750', '2014', 'Full Frame', 'Action' ],\n        [ 'Nikon', 'D800', '2011', 'Full Frame', 'Semi-Professional' ],\n        [ 'Nikon', 'D810A', '2015', 'Full Frame', 'Astro' ],\n        [ 'Nikon', 'D7100', '2013', 'APS-C', 'Expert' ],\n        [ 'Nikon', 'D6', '2020', 'Full Frame', 'Professional' ],\n        [ 'Canon', '1Ds Mark III', '2007', 'Full Frame', 'Professional' ],\n        [ 'Canon', '5D Mark II', '2008', 'Full Frame', 'Semi-Professional' ],\n        [ 'Canon', '60Da', '2012', 'APS-C', 'Astro' ],\n        [ 'Canon', '250D', '2019', 'APS-C', 'Compact' ],\n    ]\n);\n````\n\nThe Result is the following Array :\n\n````js\nconsole.log(cameras);\n````\n\n````plaitext\n[\n  [ 'Nikon', 'D3', '2007', 'Full Frame', 'Professional' ],\n  [ 'Nikon', 'D750', '2014', 'Full Frame', 'Action' ],\n  [ 'Nikon', 'D800', '2011', 'Full Frame', 'Semi-Professional' ],\n  [ 'Nikon', 'D810A', '2015', 'Full Frame', 'Astro' ],\n  [ 'Nikon', 'D7100', '2013', 'APS-C', 'Expert' ],\n  [ 'Nikon', 'D6', '2020', 'Full Frame', 'Professional' ],\n  [ 'Canon', '1Ds Mark III', '2007', 'Full Frame', 'Professional' ],\n  [ 'Canon', '5D Mark II', '2008', 'Full Frame', 'Semi-Professional' ],\n  [ 'Canon', '60Da', '2012', 'APS-C', 'Astro' ],\n  [ 'Canon', '250D', '2019', 'APS-C', 'Compact' ]\n]\n````\n\n**Important** : As field name will become methods for the table, \nthe name must respect **JavaScript** function naming convention.\n\n\n\n### Get distinct values\n\nFrom this enhanced ``Array``,\nyou can get distinct values\nby calling method where the name is one of fields set previously\nwithout parameters :\n\n````js\nconsole.log('Brand List:', cameras.Brand());\nconsole.log('Camera List:', cameras.Camera());\nconsole.log('Date List:', cameras.Date());\nconsole.log('Format List:', cameras.Format());\nconsole.log('Purpose List:', cameras.Purpose());\n````\n\nResult :\n\n````plaintext\nBrand List: [ 'Nikon', 'Canon' ]\n\nCamera List: [\n  'D3',           'D750',\n  'D800',         'D810A',\n  'D7100',        'D6',\n  '1Ds Mark III', '5D Mark II',\n  '60Da',         '250D'\n]\n\nDate List: [\n  '2007', '2008',\n  '2011', '2012',\n  '2013', '2014',\n  '2015', '2019',\n  '2020'\n]\n\nFormat List: [ 'Full Frame', 'APS-C' ]\n\nPurpose List: [\n  'Professional',\n  'Action',\n  'Semi-Professional',\n  'Astro',\n  'Expert',\n  'Compact'\n]\n````\n\n\n\n### Get rows\n\nThe main purpose of ``TableJs`` is to retrieve\nrows where the field value is equal to specified value(s).\n\n**Important**: ``TableJs`` can select rows for one field at the same time.\nBut you can chain fields to complete your selection.\n\nBelow, an example to return \nall ``Professionnal`` cameras from brand ``Nikon`` :\n\n````js\nlet NikonProCam = cameras.Brand('Nikon').Purpose('Professional');\nconsole.log('Table Result: ', NikonProCam);\nconsole.log('New Camera List: ', NikonProCam.Camera());\n````\n\nThe result is a new ``TableJs``\u003csup style=\"color: red\"\u003e_*_\u003c/sup\u003e reflecting a part of our initial table\nwhere this part is our result :\n\n\u003csup style=\"color: red\"\u003e_*_\u003c/sup\u003e This means all features stay available.\n\n````plaintext\nTable Result: [\n  [ 'Nikon', 'D3', '2007', 'Full Frame', 'Professional' ],\n  [ 'Nikon', 'D6', '2020', 'Full Frame', 'Professional' ]\n]\n\nNew Camera List: [ 'D3', 'D6' ]\n````\n\n\n\n### Get field value of row\n\nWhen you are handling a row of your table,\nyou can also call method where the name is one of field set,\nbut instead of returning distinct value, it returns the value\nof the field.\n\n````js\n// Return the camera name of the first entry\nlet cameraName = NikonProCam[0].Camera();\nconsole.log(\"Camera name of the first row:\", cameraName);\n```` \n\nResult :\n\n````plaintext\nCamera name of the first row: D3\n````\n\nRemember, you can use all existing method of Array.\nSo please find below an example to display camera name\nusing ``forEach`` method\n\n````js\nNikonProCam.forEach(function($row){\n    console.log('Camera: ', $row.Camera());\n});\n````\n\nResult :\n\n````plaintext\nCamera:  D3\nCamera:  D6\n````\n\n\n### Appending new rows\n\nTake acknowledge that the unique method which has been rewrote \nregarding the standard Array method is the ``push`` method.\n\nIn native arrays, ``push`` method add a new value in the table.\nThe rewrote method now push a new row instead of unique value.\nSo, if you push a unique value, the result will be a new row\nwhere the first field contains your single value and all other fields with\nan empty value.\nIf you push an array, if the number of values in your array\nwill not match with field number, empty field will be push at the end.\nIn case of you have more fields than those defined in ``TableJs``, \nthey stay here, but you will not have any method to retrieve them.\n\nExample by pushing a single value :\n\n````js\ncameras.push('Sony Alpha');\nconsole.log(\"Updated Cameras table:\", cameras);\n````\n\nresult :\n\n````plaintext\nUpdated Cameras table: [\n  [ 'Nikon', 'D3', '2007', 'Full Frame', 'Professional' ],\n  [ 'Nikon', 'D750', '2014', 'Full Frame', 'Action' ],\n  [ 'Nikon', 'D800', '2011', 'Full Frame', 'Semi-Professional' ],\n  [ 'Nikon', 'D810A', '2015', 'Full Frame', 'Astro' ],\n  [ 'Nikon', 'D7100', '2013', 'APS-C', 'Expert' ],\n  [ 'Nikon', 'D6', '2020', 'Full Frame', 'Professional' ],\n  [ 'Canon', '1Ds Mark III', '2007', 'Full Frame', 'Professional' ],\n  [ 'Canon', '5D Mark II', '2008', 'Full Frame', 'Semi-Professional' ],\n  [ 'Canon', '60Da', '2012', 'APS-C', 'Astro' ],\n  [ 'Canon', '250D', '2019', 'APS-C', 'Compact' ],\n  [ 'Sony Alpha', '', '', '', '' ]\n]\n````\n\nExample by pushing a row \n\n````js\ncameras.push([\n    \"Sony Alpha\", \"α 9 II\", \"2019\", \"Full Frame\", \"Sport-Pro\"\n]);\nconsole.log(\"Updated 2 Cameras table:\", cameras);\n````\n\nResult :\n\n````plaintext\nUpdated 2 Cameras table: [\n  [ 'Nikon', 'D3', '2007', 'Full Frame', 'Professional' ],\n  [ 'Nikon', 'D750', '2014', 'Full Frame', 'Action' ],\n  [ 'Nikon', 'D800', '2011', 'Full Frame', 'Semi-Professional' ],\n  [ 'Nikon', 'D810A', '2015', 'Full Frame', 'Astro' ],\n  [ 'Nikon', 'D7100', '2013', 'APS-C', 'Expert' ],\n  [ 'Nikon', 'D6', '2020', 'Full Frame', 'Professional' ],\n  [ 'Canon', '1Ds Mark III', '2007', 'Full Frame', 'Professional' ],\n  [ 'Canon', '5D Mark II', '2008', 'Full Frame', 'Semi-Professional' ],\n  [ 'Canon', '60Da', '2012', 'APS-C', 'Astro' ],\n  [ 'Canon', '250D', '2019', 'APS-C', 'Compact' ],\n  [ 'Sony Alpha', '', '', '', '' ],\n  [ 'Sony Alpha', 'α 9 II', '2019', 'Full Frame', 'Sport-Pro' ]\n]\n````\n\nPushing a new row will automatically update indexes table.\n\n````js\nconsole.log(\"Updated Cameras List:\", cameras.Camera());\n````\n\nResult :\n\n````plaintext\nUpdated Cameras List: [\n  'D3',           'D750',\n  'D800',         'D810A',\n  'D7100',        'D6',\n  '1Ds Mark III', '5D Mark II',\n  '60Da',         '250D',\n  '',             'α 9 II'\n]\n````\n\n\n### Setting (Updating) field value of one row\n\n**Important**: Keep in mind when you get a new array next to filtering using \n'field methods', updating a row in the secondary array will update the\nmain table.\n\n````js\nlet sonyCamera = cameras.Brand('Sony Alpha');\n\n// Update Row where there is no Camera Name\nlet inc = 1;\nsonyCamera.Camera('').forEach(function($row){\n    // Camera field is a component of key,\n    // So we have to set a \"unique\" name for brand (here sony)\n    $row.Camera(`Camera ${inc}`);\n    inc++;\n});\n\nconsole.log(\"Updated Sony Alpha Camera\", cameras.Brand('Sony Alpha'));\nconsole.log(\"Updated Camera Table\", cameras);\n````\n\nResult next to the update :\n\n````plaintext\nUpdated Sony Alpha Camera Table [\n  [ 'Sony Alpha', 'Camera 1', '', '', '' ],\n  [ 'Sony Alpha', 'α 9 II', '2019', 'Full Frame', 'Sport-Pro' ]\n]\n\nUpdated Camera Table [\n  [ 'Nikon', 'D3', '2007', 'Full Frame', 'Professional' ],\n  [ 'Nikon', 'D750', '2014', 'Full Frame', 'Action' ],\n  [ 'Nikon', 'D800', '2011', 'Full Frame', 'Semi-Professional' ],\n  [ 'Nikon', 'D810A', '2015', 'Full Frame', 'Astro' ],\n  [ 'Nikon', 'D7100', '2013', 'APS-C', 'Expert' ],\n  [ 'Nikon', 'D6', '2020', 'Full Frame', 'Professional' ],\n  [ 'Canon', '1Ds Mark III', '2007', 'Full Frame', 'Professional' ],\n  [ 'Canon', '5D Mark II', '2008', 'Full Frame', 'Semi-Professional' ],\n  [ 'Canon', '60Da', '2012', 'APS-C', 'Astro' ],\n  [ 'Canon', '250D', '2019', 'APS-C', 'Compact' ],\n  [ 'Sony Alpha', 'Camera 1', '', '', '' ],\n  [ 'Sony Alpha', 'α 9 II', '2019', 'Full Frame', 'Sport-Pro' ]\n]\n````\n\n\n\n### Setting (Updating) field value of result of rows\n\nTo prevent you to make a ``forEach`` loop on the array,\nyou can use method ``update()`` to set new field(s) value\nof you table or you filtered selection.\n\nBelow an example to update the **Format** ``Full Frame``\nto a detailed version ``Full Frame (24x36)`` :\n\n````js\ncameras.Format('Full Frame').update({\n    Format: 'Full Frame(24x36)'\n});\nconsole.log(\"Updated Table:\", cameras);\n````\n\nProperties of the object passed to the method ``update()``\nare the name of defined field.\n\nThe result is :\n\n````plaintext\n// \u003c\u003c\u003c is pointing updated lines\nUpdated Table: [\n  [ 'Nikon', 'D3', '2007', 'Full Frame(24x36)', 'Professional' ],              \u003c\u003c\u003c\n  [ 'Nikon', 'D750', '2014', 'Full Frame(24x36)', 'Action' ],                  \u003c\u003c\u003c\n  [ 'Nikon', 'D800', '2011', 'Full Frame(24x36)', 'Semi-Professional' ],       \u003c\u003c\u003c\n  [ 'Nikon', 'D810A', '2015', 'Full Frame(24x36)', 'Astro' ],                  \u003c\u003c\u003c\n  [ 'Nikon', 'D7100', '2013', 'APS-C', 'Expert' ],\n  [ 'Nikon', 'D6', '2020', 'Full Frame(24x36)', 'Professional' ],              \u003c\u003c\u003c\n  [ 'Canon', '1Ds Mark III', '2007', 'Full Frame(24x36)', 'Professional' ],    \u003c\u003c\u003c\n  [ 'Canon', '5D Mark II', '2008', 'Full Frame(24x36)', 'Semi-Professional' ], \u003c\u003c\u003c\n  [ 'Canon', '60Da', '2012', 'APS-C', 'Astro' ],\n  [ 'Canon', '250D', '2019', 'APS-C', 'Compact' ],\n  [ 'Sony Alpha', 'Camera 1', '', '', '' ],\n  [ 'Sony Alpha', 'α 9 II', '2019', 'Full Frame(24x36)', 'Sport-Pro' ]         \u003c\u003c\u003c\n]\n\n````\n\n\n\n### Delete rows from the table\n\nIn the same way of method ``update()`` which allows you to make a mass update,\nyou can massively delete rows next to a selection.\nThe method is ``delete()`` and it purposed to used next to a selection\nmade by calling _'field method'_.\nCalled on the main table, it will drop entirely the table.\n\nBelow an example to clear all ``APS-C`` Camera in the table :\n\n````js\ncameras.Format('APS-C').delete();\nconsole.log(cameras);\n````\n\nresult :\n\n````plaintext\n[\n  [ 'Nikon', 'D3Rename', '2007', 'Full Frame(24x36)', 'Professional' ],\n  [ 'Nikon', 'D750', '2014', 'Full Frame(24x36)', 'Action' ],\n  [ 'Nikon', 'D800', '2011', 'Full Frame(24x36)', 'Semi-Professional' ],\n  [ 'Nikon', 'D810A', '2015', 'Full Frame(24x36)', 'Astro' ],\n  [ 'Nikon', 'D6', '2020', 'Full Frame(24x36)', 'Professional' ],\n  [ 'Canon', '1Ds Mark III', '2007', 'Full Frame(24x36)', 'Professional' ],\n  [ 'Canon', '5D Mark II', '2008', 'Full Frame(24x36)', 'Semi-Professional' ],\n  [ 'Sony Alpha', 'Camera 1', '', '', '' ],\n  [ 'Sony Alpha', 'α 9 II', '2019', 'Full Frame(24x36)', 'Sport-Pro' ]\n]\n````\n\n\n\n\n\n### Make a copy of table\n\nAs saw previously in chapter ``Setting (Updating) field value of one row``\nand as it in standard, Arrays work with references.\nUpdating a row in intermediate variable will update the table.\n\n``TableJs`` comes with a dedicated method named `copy`\nto get a full new table where reference are broken.\n\nPlease find below normal behavior using reference\n\n````js\nlet D3Cam  = cameras.Camera('D3');          // Table with 1 row\nlet D3Cam2 = D3Cam;                         // This is not a copy\nD3Cam2[0].Camera('D3Rename');               // Rename the camera name\n\nconsole.log(\"D3Cam:  \", D3Cam);             // D3 --\u003e D3Rename\nconsole.log(\"D3Cam2: \", D3Cam2);            // D3 --\u003e D3Rename\nconsole.log(\"Cameras Table: \", cameras);    // D3 --\u003e D3Rename\n````\n\nResult\n\n````plaintext\nD3Cam:   [ [ 'Nikon', 'D3Rename', '2007', 'Full Frame', 'Professional' ] ]\n\nD3Cam2:  D3Rename\n\nCameras Table:  [\n  [ 'Nikon', 'D3Rename', '2007', 'Full Frame', 'Professional' ],       \u003c\u003c Also updated\n  [ 'Nikon', 'D750', '2014', 'Full Frame', 'Action' ],\n  [ 'Nikon', 'D800', '2011', 'Full Frame', 'Semi-Professional' ],\n  [ 'Nikon', 'D810A', '2015', 'Full Frame', 'Astro' ],\n  [ 'Nikon', 'D7100', '2013', 'APS-C', 'Expert' ],\n  [ 'Nikon', 'D6', '2020', 'Full Frame', 'Professional' ],\n  [ 'Canon', '1Ds Mark III', '2007', 'Full Frame', 'Professional' ],\n  [ 'Canon', '5D Mark II', '2008', 'Full Frame', 'Semi-Professional' ],\n  [ 'Canon', '60Da', '2012', 'APS-C', 'Astro' ],\n  [ 'Canon', '250D', '2019', 'APS-C', 'Compact' ],\n  [ 'Sony Alpha', 'Camera 1', '', '', '' ],\n  [ 'Sony Alpha', 'α 9 II', '2019', 'Full Frame', 'Sport-Pro' ]\n]\n````\n\nNow the same process using ``copy()`` :\n\n````js\nlet D6Cam  = cameras.Camera('D6');          // Table with 1 row\nlet D6Cam2 = D6Cam.copy();                  // Make a true copy of the table\nD6Cam2[0].Camera('D6Rename');               // Rename the camera name\n\nconsole.log(\"D6Cam:  \", D6Cam);             // D6 --\u003e D6\nconsole.log(\"D6Cam2: \", D6Cam2);            // D6 --\u003e D6Rename\nconsole.log(\"Cameras Table: \", cameras);    // D6 --\u003e D6\n````\n\nResult :\n\n````plaintext\nD6Cam:   [ [ 'Nikon', 'D6', '2020', 'Full Frame', 'Professional' ] ]\n\nD6Cam2:  [ [ 'Nikon', 'D6Rename', '2020', 'Full Frame', 'Professional' ] ]\n\nCameras Table:  [\n  [ 'Nikon', 'D3', '2007', 'Full Frame', 'Professional' ],\n  [ 'Nikon', 'D750', '2014', 'Full Frame', 'Action' ],\n  [ 'Nikon', 'D800', '2011', 'Full Frame', 'Semi-Professional' ],\n  [ 'Nikon', 'D810A', '2015', 'Full Frame', 'Astro' ],\n  [ 'Nikon', 'D7100', '2013', 'APS-C', 'Expert' ],\n  [ 'Nikon', 'D6', '2020', 'Full Frame', 'Professional' ],              \u003c\u003c Unchange\n  [ 'Canon', '1Ds Mark III', '2007', 'Full Frame', 'Professional' ],\n  [ 'Canon', '5D Mark II', '2008', 'Full Frame', 'Semi-Professional' ],\n  [ 'Canon', '60Da', '2012', 'APS-C', 'Astro' ],\n  [ 'Canon', '250D', '2019', 'APS-C', 'Compact' ],\n  [ 'Sony Alpha', 'Camera 1', '', '', '' ],\n  [ 'Sony Alpha', 'α 9 II', '2019', 'Full Frame', 'Sport-Pro' ]\n]\n````\n\n\nFor more features, please confer to **detailed documentation**.\n\n\u003chr /\u003e\n\n\n\n### Using objects as the source of data for TableJs\n\n``TableJs`` is able to handle objects as the source of the data.\n\nIndeed, depending on your needs,\nyou can prefer working with objects that are easier to manipulate\nand use in your application.\n\nIn that case, ``TableJs`` offer all features to\nfilter, get and set while keeping the object as is.\nBoth are bound together and all modifications are\nreflected to the other.\n\nThere are only three requirements to work with objects: \n\n- Field names must be defined before setting data or at the\nsame time during global initialization.\n- Objects are wrapped in an array : ``Array of Object``\n- Objects in the array must have the same definition of properties\n\nPlease find below an example with cameras, \nbut data structured in a ``Array of Object`` : \n\n````js\nlet aObjectCamera = [\n    {'Brand': 'Nikon', 'Camera': 'D3', 'Date': '2007', 'Format': 'Full Frame', 'Purpose': 'Professional'},\n    {'Brand': 'Nikon', 'Camera': 'D750', 'Date': '2014', 'Format': 'Full Frame', 'Purpose': 'Action'},\n    {'Brand': 'Nikon', 'Camera': 'D800', 'Date': '2011', 'Format': 'Full Frame', 'Purpose': 'Semi-Professional'},\n    {'Brand': 'Nikon', 'Camera': 'D810A', 'Date': '2015', 'Format': 'Full Frame', 'Purpose': 'Astro'},\n    {'Brand': 'Nikon', 'Camera': 'D7100', 'Date': '2013', 'Format': 'APS-C', 'Purpose': 'Expert'},\n    {'Brand': 'Nikon', 'Camera': 'D6', 'Date': '2020', 'Format': 'Full Frame', 'Purpose': 'Professional'},\n    {'Brand': 'Canon', 'Camera': '1Ds Mark III', 'Date': '2007', 'Format': 'Full Frame', 'Purpose': 'Professional'},\n    {'Brand': 'Canon', 'Camera': '5D Mark II', 'Date': '2008', 'Format': 'Full Frame', 'Purpose': 'Semi-Professional'},\n    {'Brand': 'Canon', 'Camera': '60Da', 'Date': '2012', 'Format': 'APS-C', 'Purpose': 'Astro'},\n    {'Brand': 'Canon', 'Camera': '250D', 'Date': '2019', 'Format': 'APS-C', 'Purpose': 'Compact'}\n];\n\nlet cameras = new TableJs(\n    // List of Fields (At least one required)\n    ['Brand', 'Camera', 'Date', 'Format', 'Purpose'],\n\n    // Indicating that fields compose the key\n    // -\u003e Optional, but at least empty Array must be passed\n    ['Camera', 'Brand'],\n\n    // Table Data : Array of Object\n    aObjectCamera\n);\n\nclog(\"Witness:\");\nclog(\"aObjectCamera[0].Brand (Expected Nikon):\", aObjectCamera[0].Brand);\nclog(\"cameras[0].Brand() (Expected Nikon):\", cameras[0].Brand());\nclog(\"---------------------------------------------------------------\");\nclog(\"Statement: cameras[0].Brand('test')\");\n// Modification from TableJs using methods\ncameras[0].Brand('test');\nclog(\"aObjectCamera[0].Brand (Expected test):\", aObjectCamera[0].Brand);\nclog(\"cameras[0].Brand() (Expected test):\", cameras[0].Brand());\nclog(\"---------------------------------------------------------------\");\nclog(\"Statement: aObjectCamera[0].Brand = 'demo'\");\n// Modification from original array providing data, modifying the property\naObjectCamera[0].Brand = 'demo';\nclog(\"aObjectCamera[0].Brand (Expected demo):\", aObjectCamera[0].Brand);\nclog(\"cameras[0].Brand() (Expected demo):\", cameras[0].Brand());\n````\n\nBelow the result of output : \n\n````plaintext\nWitness:\naObjectCamera[0].Brand (Expected Nikon): Nikon\ncameras[0].Brand() (Expected Nikon): Nikon\n---------------------------------------------------------------\nStatement: cameras[0].Brand('test')\naObjectCamera[0].Brand (Expected test): test\ncameras[0].Brand() (Expected test): test\n---------------------------------------------------------------\nStatement: aObjectCamera[0].Brand = 'demo'\naObjectCamera[0].Brand (Expected demo): demo\ncameras[0].Brand() (Expected demo): demo\n\n````\n\n\n\n\n\n\n## Detailed documentation\n\nFrom this point, you will find the detailed documentation with all\nuser method. Internal method will not be detailed (even if they are callable).\n\n\n### Minimal Instantiation\n\nYou can easily create a new **TableJs** instance like this :\n\n````js\nlet cameras = new TableJs(); // Will return an empty Array\n````\n\n\n\n### Managing fields\n\nField can be managed later next to the **TableJs** instantiation.\nThat allows you to use **TableJs** dynamically.\n\nFields manager is available from your array and return some sub method : \n``cameras.fields()``.\n\n\n\n#### Method ``set``\n\nThe method ``set()`` defines the field list.\nThis method will overwrite existing field list.\nIf you only want to add a new field, please confer to method\n``add()``.\n\nIt accept none to many argument with following type :\n* **String**\n* **Array** of **String**\n\n**Important**: Field name must respect the naming convention of functions name.\nFor instance, a field can not start with a number.\n\nSample :\n\n````js\nlet cameras = new TableJs(); // Will return an empty Array\n\ncameras.fields().set( 'Field1', 'Field2', ['Field3', 'Field4'] );\n````\n\nEach defined field will generates a method on the **Array** and\non each **rows** of the Array.\nPlease confer chapter ``Dynamic Methods`` in this **detailed documentation**.\n\n\n\n#### Method ``add``\n\n\n\n\n#### Method ``get``\n\n\n\n\n\n\n### Managing keys\n\n\n#### Method ``set``\n\n#### Method ``add``\n\n#### Method ``get``\n\n\n\n\n\n\n### Managing Data\n\n\n#### Method ``set``\n\n#### Method ``add`` (Alias `append`)\n\n#### Method ``get``\n\n#### Method ``getRow``\n\n\n\n\n\n\n### Dynamic Methods\n\nEach defined field will generates a method on the **Array** and\non each **rows** of the Array.\n\n\n#### Method ``MyField()`` on the Array\n\n\n#### Method ``MyField()`` on a row of the Array\n\n\n\n\n\n\n### Extra method\n\n#### Method ``setDeprecated``\n\n#### Method ``deleteRow``\n\n\n \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneooblaster%2Ftablejs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fneooblaster%2Ftablejs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fneooblaster%2Ftablejs/lists"}