Closed Ken-LiuL closed 6 years ago
You'll need to define a Buffer
type, then create a Sanctuary module with a custom environment which includes that type:
const {create, env} = require ('sanctuary');
const $ = require ('sanctuary-def');
// BufferType :: Type
const BufferType = $.NullaryType
('my-package/Buffer')
('https://my-package.org/#Buffer')
(Buffer.isBuffer);
const S = create ({checkTypes: true, env: env.concat ([BufferType])});
Let me know if this approach works for you, @Charles-Lau-.
it seems I need to define this for each types that are not defined in 'sanctuary-def', this works after I define all of them
That's right, @Charles-Lau-. If you believe some of your type definitions are general enough to warrant inclusion in $.env
, please raise an issue.
@davidchambers This is really useful when using sanctuary with NodeJS. Would love to see it become part of $.env
. What's necessary to get it in there?
when use Buffer type in S.either, it will throw type unsupported error, if type check is open