{"id":18865297,"url":"https://github.com/jonathanprince/brita","last_synced_at":"2026-02-12T09:30:18.308Z","repository":{"id":21800347,"uuid":"25122898","full_name":"JonathanPrince/brita","owner":"JonathanPrince","description":"Object Filter Module for nodejs","archived":false,"fork":false,"pushed_at":"2014-11-03T18:44:51.000Z","size":500,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-31T01:28:56.170Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://jonathanprince.github.io/brita","language":"JavaScript","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/JonathanPrince.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}},"created_at":"2014-10-12T15:11:59.000Z","updated_at":"2016-12-28T08:05:31.000Z","dependencies_parsed_at":"2022-08-19T22:02:32.581Z","dependency_job_id":null,"html_url":"https://github.com/JonathanPrince/brita","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JonathanPrince%2Fbrita","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JonathanPrince%2Fbrita/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JonathanPrince%2Fbrita/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JonathanPrince%2Fbrita/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JonathanPrince","download_url":"https://codeload.github.com/JonathanPrince/brita/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239809374,"owners_count":19700608,"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-08T04:46:35.360Z","updated_at":"2026-02-12T09:30:18.104Z","avatar_url":"https://github.com/JonathanPrince.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"#brita\n\n[![Build Status](https://travis-ci.org/JonathanPrince/brita.svg?branch=master)](https://travis-ci.org/JonathanPrince/brita)\n\n[![NPM](https://nodei.co/npm/brita.png?downloads=true)](https://nodei.co/npm/brita/)\n\n##Description\nObject Filter Module for nodejs\n\n###Syntax\n`brita(object, filter)`\n\n####Parameters\n**object**\n\n  Object to be filtered\n\n**filter**\n\n  Function or Object.\n\n  A function to be used to filter the object, should return true or false.\n\n  An object containing filter options.\n\n##Usage\nInstall the brita module using npm\n```\n$ npm install brita\n```\n Basic Example\n```js\n// require brita module\nvar brita = require('brita');\n\n// object to be filtered\nvar myObject = {\n    key1: 1,\n    key2: 2,\n    key3: 3,\n    key4: 4\n};\n\n// filter function\nvar myFilter = function(value){\n\n    // return true for values less than 3\n    if (value \u003c 3) {\n        return true;\n    } else {\n        return false;\n    }\n};\n\n// apply filter to create new object filtered by brita\nvar filteredObject = brita(myObject, myFilter);\n\n// output from brita has been assigned to filteredObject\nconsole.log(filteredObject)             //   returns { key1: 1, key2: 2 }\n\n```\n\n###Using built in filter options\n\nBuilt-in filter options can be used by passing an object as the second parameter.\n\n| Key     | value      | Description      |\n|---------|------------|------------------|\n| valueType   | 'string'   |returns all key value pairs with values that are strings |\n| valueType   | 'number'   |returns all key value pairs with values that are numbers |\n| valueType   | 'boolean'  |returns all key value pairs with values that are booleans |\n| valueType   | 'array'    |returns all key value pairs with values that are arrays   |\n| valueType   | 'object'   |returns all key value pairs with values that are objects  |\n| valueType   | 'regex'    |returns all key value pairs with values that are regular expressions |\n| keyFilter   | RegExp     |returns all key value pairs with keys that match regular expression |\n\n\nExample using built-in type filter\n```js\n// require brita module\nvar brita = require('brita');\n\n// object to be filtered\nvar myObject = {\n    key1: 1,\n    key2: '2',\n    key3: 3,\n    key4: '4'\n};\n\n// apply filter to create new object filtered by brita\nvar filteredObject = brita(myObject, {valueType: 'string'});\n\n// output from brita has been assigned to filteredObject\nconsole.log(filteredObject);             //   returns { key2: '2', key4: '4' }\n\n```\n\nExample using regular expression to filter by key\n```js\n// require brita module\nvar brita = require('brita');\n\n// object to be filtered\nvar myObject = {\n  abc1: 'a',\n  abc2: 'b',\n  def1: 'c',\n  def2: 'd'\n};\n\n//apply filter to create new object filter by brita\nvar filteredObject = brita(myObject, {keyFilter: /abc/});\n\n// output from brita has been assigned to filteredObject\nconsole.log(filteredObject);             //   returns { abc1: 'a', abc2: 'b' }\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonathanprince%2Fbrita","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjonathanprince%2Fbrita","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjonathanprince%2Fbrita/lists"}