chbrown / rfc6902

Complete implementation of RFC6902 in TypeScript
https://chbrown.github.io/rfc6902/
322 stars 39 forks source link

Export Pointer class from module #45

Closed mmiller42 closed 5 years ago

mmiller42 commented 5 years ago

It would be useful to be able to import the Pointer class so that we can easily parse JSON pointers to token arrays as well.

chbrown commented 5 years ago

Please note that you can import and use Pointer like:

const {Pointer} = require('rfc6902/pointer')
Pointer.fromJSON('/a/b')
//=> Pointer { tokens: [ '', 'a', 'b' ] }

I think it's important to keep the surface area of the root-level module small (currently only three exports) and relevant (all of which are specific to RFC 6902). Since JSON Pointers are defined in RFC 6901, and not required to use the root-level imports, I don't think they belong in the root module. But if you have a compelling use-case in mind, I could be persuaded. Or perhaps it'd suffice to add a couple lines like the snippet above to the documentation (i.e., README.md)?

mmiller42 commented 5 years ago

Thanks! I think adding that other modules are exported besides the entry point to the docs would be useful. I should've checked the dist folder.