├── .gitignore ├── tea.yaml ├── src └── autocomplete.js ├── test └── index.test.js ├── package.json ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Directories 2 | node_modules/ 3 | dist/ 4 | coverage/ 5 | .cache/ 6 | 7 | # Files 8 | .env 9 | .DS_Store -------------------------------------------------------------------------------- /tea.yaml: -------------------------------------------------------------------------------- 1 | # https://tea.xyz/what-is-this-file 2 | --- 3 | version: 1.0.0 4 | codeOwners: 5 | - '0x9BAac40A197bbb110ae5B2f31342D8d15D734832' 6 | - '0xC4C902Ada8DB1dDae5e7641E4c392C1abF0b785A' 7 | quorum: 1 8 | -------------------------------------------------------------------------------- /src/autocomplete.js: -------------------------------------------------------------------------------- 1 | class Autocomplete { 2 | constructor(data) { 3 | this.data = data; 4 | } 5 | 6 | search(query) { 7 | return this.data.filter(item => item.toLowerCase().includes(query.toLowerCase())); 8 | } 9 | } 10 | 11 | module.exports = Autocomplete; 12 | -------------------------------------------------------------------------------- /test/index.test.js: -------------------------------------------------------------------------------- 1 | const assert = require('assert'); 2 | const Autocomplete = require('../src/autocomplete'); 3 | 4 | describe('Autocomplete', function () { 5 | it('should return matching items', function () { 6 | const data = ['apple', 'banana', 'orange', 'pineapple', 'grape']; 7 | const autocomplete = new Autocomplete(data); 8 | const result = autocomplete.search('ap'); 9 | 10 | assert.deepStrictEqual(result, ['apple', 'pineapple', 'grape']); 11 | }); 12 | 13 | it('should return empty array for no match', function () { 14 | const data = ['apple', 'banana', 'orange', 'pineapple', 'grape']; 15 | const autocomplete = new Autocomplete(data); 16 | const result = autocomplete.search('z'); 17 | 18 | assert.deepStrictEqual(result, []); 19 | }); 20 | }); 21 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "onedionys-input-autocomplete", 3 | "version": "5.0.0", 4 | "description": "One Dionys (Input Autocomplete) - Functions to provide recommendations or auto-complete user input in forms.", 5 | "main": "src/autocomplete.js", 6 | "directories": { 7 | "test": "test" 8 | }, 9 | "scripts": { 10 | "test": "mocha" 11 | }, 12 | "repository": { 13 | "type": "git", 14 | "url": "https://github.com/onedionys/onedionys-input-autocomplete.git" 15 | }, 16 | "keywords": [ 17 | "onedionys", 18 | "tea", 19 | "package-manager", 20 | "input-autocomplete" 21 | ], 22 | "author": "One Dionys", 23 | "license": "ISC", 24 | "bugs": { 25 | "url": "https://github.com/onedionys/onedionys-input-autocomplete/issues" 26 | }, 27 | "homepage": "https://github.com/onedionys/onedionys-input-autocomplete#readme", 28 | "dependencies": { 29 | "@types/chai": "^4.3.12", 30 | "@types/mocha": "^10.0.6", 31 | "chai": "^5.1.0", 32 | "mocha": "^10.3.0" 33 | }, 34 | "devDependencies": { 35 | "chai": "^5.1.0", 36 | "mocha": "^10.3.0" 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2024 ONE DIONYS 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

Welcome to One Dionys - Input Autocomplete! 👋

2 | 3 |

Functions to provide recommendations or auto-complete user input in forms. 💖

4 | 5 |

6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |

14 | 15 | ## 💾 Requirements 16 | 17 | * `Web Browser` - Can be used as an emulator to build applications. Example [Chrome, Firefox, Safari & Opera]. 18 | * `Internet` - Because many use CDN and to make it easier to find solutions to all problems. 19 | 20 | ## 🎯 How To Use 21 | 22 | #### Example Syntax 23 | 24 | ```javascript 25 | const Autocomplete = require('./src/autocomplete'); 26 | 27 | // Example usage 28 | const data = ['apple', 'banana', 'orange', 'pineapple', 'grape']; 29 | const autocomplete = new Autocomplete(data); 30 | 31 | // Searching for items 32 | const result = autocomplete.search('a'); 33 | console.log(result); // Output: ['apple', 'banana', 'orange', 'grape'] 34 | ``` 35 | 36 | #### Explanation 37 | 38 | * This package provides a simple autocomplete functionality for input fields. It takes an array of data as input and returns matching items based on the query string provided. 39 | 40 | #### Return Value 41 | 42 | * The search method of the Autocomplete class returns an array containing the items that match the query string provided. If no match is found, it returns an empty array. 43 | 44 | ## 📆 Release Date 45 | 46 | * v1.0.0 : 08 March 2024 47 | * v1.0.1 : 11 March 2024 48 | * v4.0.0 : 11 March 2024 49 | * v4.0.1 : 14 March 2024 50 | * v4.0.2 : 18 March 2024 51 | * v5.0.0 : 31 March 2024 52 | 53 | ## 🧑 Author 54 | 55 | * Facebook : Oned Ionys 56 | * Instagram : @onedionys 57 | * Twitter : @onedionys 58 | * LinkedIn : @onedionys 59 | 60 | ## 📝 License 61 | 62 | * Copyright © 2024 One Dionys 63 | * **One Dionys - Input Autocomplete is an open source project licensed under the MIT license** 64 | 65 | ## ☕️ Suppport & Donation 66 | 67 | Love One Dionys - Input Autocomplete? Support this project by donating or sharing with others in need. 68 | 69 | 70 | 71 | **Made with ❤️ One Dionys** 72 | --------------------------------------------------------------------------------