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.

readme.md 2.3KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. # css-select-base-adapter
  2. Provides some base functions needed by a
  3. [`css-select`](https://github.com/fb55/css-select) adapter so that you don't
  4. have to implement the whole thing.
  5. ## usage
  6. `npm install css-select-base-adapter --save`
  7. ```javascript
  8. var baseAdapter = require('css-select-base-adapter');
  9. var myAdapter = {
  10. // your partial implementation here
  11. };
  12. // get an adapter with everything needed by css-select
  13. var adapter = baseAdapter(myAdapter);
  14. // use adapter with css-select...
  15. ```
  16. ## how it works
  17. An adapter for `css-select` requires the following functions to be implemented:
  18. ```
  19. isTag, existsOne, getAttributeValue, getChildren, getName, getParent,
  20. getSiblings, getText, hasAttrib, removeSubsets, findAll, findOne
  21. ```
  22. You can pass this module a more minimal implementation and it will return a full
  23. adapter that fills in any missing functions, provided that you implement at
  24. least:
  25. ```
  26. isTag, getAttributeValue, getChildren, getName, getParent, getText
  27. ```
  28. If you provide any of the other methods required of an adapter, the base adapter
  29. will use your implementation instead of its own.
  30. See the
  31. [`css-select` readme](https://github.com/fb55/css-select/blob/master/README.md)
  32. for more information on the required function signatures.
  33. ## license
  34. MIT License
  35. Copyright (c) 2018 Nik Coughlin
  36. Permission is hereby granted, free of charge, to any person obtaining a copy
  37. of this software and associated documentation files (the "Software"), to deal
  38. in the Software without restriction, including without limitation the rights
  39. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  40. copies of the Software, and to permit persons to whom the Software is
  41. furnished to do so, subject to the following conditions:
  42. The above copyright notice and this permission notice shall be included in all
  43. copies or substantial portions of the Software.
  44. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  45. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  46. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  47. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  48. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  49. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  50. SOFTWARE.