{"id":19042000,"url":"https://github.com/writetome51/public-array-getter-remover","last_synced_at":"2026-02-12T01:41:55.384Z","repository":{"id":122062457,"uuid":"153859688","full_name":"writetome51/public-array-getter-remover","owner":"writetome51","description":"An array-manipulating typescript/javascript class that removes and returns items in the array","archived":false,"fork":false,"pushed_at":"2019-06-10T02:27:45.000Z","size":59,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-03T11:51:21.311Z","etag":null,"topics":["array-manipulations","elements","items","javascript","remove","remover","return","typescript"],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/writetome51.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2018-10-20T01:46:20.000Z","updated_at":"2019-06-10T02:27:47.000Z","dependencies_parsed_at":"2023-07-25T07:09:13.862Z","dependency_job_id":null,"html_url":"https://github.com/writetome51/public-array-getter-remover","commit_stats":null,"previous_names":["writetome51/open-array-item-getter-remover","writetome51/public-array-item-getter-remover"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/writetome51%2Fpublic-array-getter-remover","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/writetome51%2Fpublic-array-getter-remover/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/writetome51%2Fpublic-array-getter-remover/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/writetome51%2Fpublic-array-getter-remover/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/writetome51","download_url":"https://codeload.github.com/writetome51/public-array-getter-remover/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240100512,"owners_count":19747683,"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":["array-manipulations","elements","items","javascript","remove","remover","return","typescript"],"created_at":"2024-11-08T22:33:46.609Z","updated_at":"2026-02-12T01:41:50.365Z","avatar_url":"https://github.com/writetome51.png","language":"TypeScript","readme":"# PublicArrayGetterRemover\n\nAn array-manipulating TypeScript/JavaScript class with methods that both remove   \nand return items from the array.\n\n\n## Constructor\n```ts\nconstructor(data? = [])  // 'data' is assigned to this.data .\n```\n\nYou can reset the array by accessing the class `.data` property:\n```ts\nthis.data = [1,2,3,4];\n```\n\n## Properties\n```ts\ndata : any[]  // the actual array\n\nclassName: string (read-only)\n```\n\t\n\t\n## Methods\n\u003cdetails\u003e\n\u003csummary\u003eview methods\u003c/summary\u003e\n\n```ts\nbyIndex(index): any\n    // removes and returns item identified by index.  index can be negative or positive.\n\nbyIndexes(indexes): any[]\n    // removes and returns items identified by indexes.  indexes can be negative or positive.\n\nhead(numItemsToRemove): any[]\n    // removes and returns numItemsToRemove from beginning of this.data\n\ntail(numItemsToRemove): any[]\n    // removes and returns numItemsToRemove from end of this.data\n\nbetween(numItemsToKeepAtEachEnd): any[]\n    // removes and returns middle of this.data, between numItemsToIgnoreAtEachEnd\n\nadjacentAt(startingIndex, numItemsToRemove): any[]\n    // Beginning at startingIndex, removes and returns adjacent numItemsToRemove.\n    // startingIndex can be negative or positive.\n```\nNOTICE:  For all the functions below, the parameter `value` cannot be an object.  \nIt can be an array, as long as the array doesn't contain objects.\n```ts\nadjacentToValue(info): any[]\n    /**************\n    removes and returns adjacent items including, or near, a particular value.\n    Only applies to the first instance of value found in array.\n    The parameter 'info' is an object that looks like this:\n    {\n        value: any except object (the value to search for in the array),\n        offset: integer (tells function where, in relation to value, to begin selecting adjacent\n                items to remove/return.  If offset is zero, the selection will begin with value.)\n        howMany: integer greater than zero (it's how many adjacent items to remove/return)\n    }\n    Example:\n        let getAndRemove = new PublicArrayGetterRemover( [1,2,3,4,5,6,7,8,9,10] );\n        let numbers = getAndRemove.adjacentToValue({value:5, offset: -2, howMany:3});\n        // numbers is now [3,4,5].  getAndRemove.data is now [1,2,6,7,8,9,10]\n    **************/\n            \nallAfterFirst(value): any[]\n    // removes and returns everything after first instance of value\n\nallBeforeFirst(value): any[]\n    // removes and returns everything before first instance of value\n\nallAfterLast(value): any[]\n    // removes and returns everything after last instance of value\n\nallBeforeLast(value): any[]\n    // removes and returns everything before last instance of value\n\nduplicates(): any[]\n    // removes and returns every instance of a duplicate, so you may get multiple instances.\n```\n\nThe next 2 methods return an array of IValueIndexPairs.   \nA IValueIndexPair looks like this:  `{value: any,  index: integer}`  \nIt represents an array item.\n```ts\nbyTest(testFunction: (currentValue, currentIndex?, array?) =\u003e boolean): IValueIndexPair[]\n    // removes and returns any item that passes testFunction.\n\nbyType(\n    type: 'object' | 'array' | 'number' | 'string' | 'boolean' | 'function' | 'undefined' | 'null'\n): IValueIndexPair[]\n    // removes and returns any item of the passed type.\n    // Here, 'null' is considered its own type, separate from 'object'.\n    // You can also pass 'array' as a type.  Passing 'object' will match with objects and arrays.\n\n``` \nThe methods below are not important to know about in order to use this  \nclass.  They're inherited from [BaseClass](https://github.com/writetome51/typescript-base-class#baseclass) .\n```ts\nprotected   _createGetterAndOrSetterForEach(\n\t\tpropertyNames: string[],\n\t\tconfiguration: IGetterSetterConfiguration\n\t   ) : void\n    /*********************\n    Use this method when you have a bunch of properties that need getter and/or \n    setter functions that all do the same thing. You pass in an array of string \n    names of those properties, and the method attaches the same getter and/or \n    setter function to each property.\n    IGetterSetterConfiguration is this object:\n    {\n        get_setterFunction?: (\n             propertyName: string, index?: number, propertyNames?: string[]\n        ) =\u003e Function,\n\t    // get_setterFunction takes the property name as first argument and \n\t    // returns the setter function.  The setter function must take one \n\t    // parameter and return void.\n\t    \n        get_getterFunction?: (\n             propertyName: string, index?: number, propertyNames?: string[]\n        ) =\u003e Function\n\t    // get_getterFunction takes the property name as first argument and \n\t    // returns the getter function.  The getter function must return something.\n    }\n    *********************/ \n\t   \n\t   \nprotected   _returnThis_after(voidExpression: any) : this\n    // voidExpression is executed, then function returns this.\n    // Even if voidExpression returns something, the returned data isn't used.\n\nprotected   _errorIfPropertyHasNoValue(\n                property: string, // can contain dot-notation, i.e., 'property.subproperty'\n                propertyNameInError? = ''\n            ) : void\n    // If value of this[property] is undefined or null, it triggers fatal error:\n    // `The property \"${propertyNameInError}\" has no value.`\n```\n\u003c/details\u003e\n\n## Inheritance Chain\n\nPublicArrayGetterRemover\u003c--[PublicArrayContainer](https://github.com/writetome51/public-array-container#publicarraycontainer)\u003c--[BaseClass](https://github.com/writetome51/typescript-base-class#baseclass)\n\n\n## Installation\n\n```bash\nnpm i  @writetome51/public-array-getter-remover\n```\n\n## Loading\n```ts\n// if using TypeScript:\nimport {PublicArrayGetterRemover} from '@writetome51/public-array-getter-remover';\n// if using ES5 JavaScript:\nvar PublicArrayGetterRemover = \n\trequire('@writetome51/public-array-getter-remover').PublicArrayGetterRemover;\n```\n\n\n## License\n[MIT](https://choosealicense.com/licenses/mit/)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwritetome51%2Fpublic-array-getter-remover","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwritetome51%2Fpublic-array-getter-remover","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwritetome51%2Fpublic-array-getter-remover/lists"}