You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

87 lines
2.4 KiB

6 months ago
  1. # wildcard
  2. Very simple wildcard matching, which is designed to provide the same
  3. functionality that is found in the
  4. [eve](https://github.com/adobe-webplatform/eve) eventing library.
  5. [![NPM](https://nodei.co/npm/wildcard.png)](https://nodei.co/npm/wildcard/)
  6. [![stable](https://img.shields.io/badge/stability-stable-green.svg)](https://github.com/dominictarr/stability#stable)
  7. ## Usage
  8. It works with strings:
  9. ```js
  10. var wildcard = require('wildcard');
  11. console.log(wildcard('foo.*', 'foo.bar'));
  12. // --> true
  13. console.log(wildcard('foo.*', 'foo'));
  14. // --> true
  15. ```
  16. Arrays:
  17. ```js
  18. var wildcard = require('wildcard');
  19. var testdata = [
  20. 'a.b.c',
  21. 'a.b',
  22. 'a',
  23. 'a.b.d'
  24. ];
  25. console.log(wildcard('a.b.*', testdata));
  26. // --> ['a.b.c', 'a.b', 'a.b.d']
  27. ```
  28. Objects (matching against keys):
  29. ```js
  30. var wildcard = require('wildcard');
  31. var testdata = {
  32. 'a.b.c' : {},
  33. 'a.b' : {},
  34. 'a' : {},
  35. 'a.b.d' : {}
  36. };
  37. console.log(wildcard('a.*.c', testdata));
  38. // --> { 'a.b.c': {} }
  39. ```
  40. ## Alternative Implementations
  41. * <https://github.com/isaacs/node-glob>
  42. Great for full file-based wildcard matching.
  43. * <https://github.com/sindresorhus/matcher>
  44. A well cared for and loved JS wildcard matcher.
  45. ## License(s)
  46. ### MIT
  47. Copyright (c) 2023 Damon Oehlman <&#x6d;&#x61;&#105;&#108;&#116;&#x6f;&#x3a;&#x64;&#x61;&#109;&#111;&#110;&#46;&#111;&#101;&#x68;&#108;&#x6d;&#97;&#x6e;&#x40;&#x67;&#x6d;&#x61;&#x69;&#x6c;&#x2e;&#x63;&#111;&#109;>
  48. Permission is hereby granted, free of charge, to any person obtaining
  49. a copy of this software and associated documentation files (the
  50. 'Software'), to deal in the Software without restriction, including
  51. without limitation the rights to use, copy, modify, merge, publish,
  52. distribute, sublicense, and/or sell copies of the Software, and to
  53. permit persons to whom the Software is furnished to do so, subject to
  54. the following conditions:
  55. The above copyright notice and this permission notice shall be
  56. included in all copies or substantial portions of the Software.
  57. THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
  58. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  59. MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
  60. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
  61. CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
  62. TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
  63. SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.