diff --git a/index.js b/index.js
index 221a25a..5037086 100644
--- a/index.js
+++ b/index.js
@@ -615,6 +615,18 @@
([])
(typeofEq ('boolean'));
+ //# Buffer :: Type
+ //.
+ //. Type comprising every [Buffer][] object.
+ var Buffer_ = NullaryTypeWithUrl
+ ('Buffer')
+ ([])
+ (function(x) {
+ return typeof Buffer !== 'undefined' &&
+ // eslint-disable-next-line no-undef
+ Buffer.isBuffer (x);
+ });
+
//# Date :: Type
//.
//. Type comprising every Date value.
@@ -1054,6 +1066,7 @@
//. - [Array](#Array) ([Unknown][])
//. - [Array2](#Array2) ([Unknown][]) ([Unknown][])
//. - [Boolean](#Boolean)
+ //. - [Buffer](#Buffer)
//. - [Date](#Date)
//. - [Descending](#Descending) ([Unknown][])
//. - [Either](#Either) ([Unknown][]) ([Unknown][])
@@ -1082,6 +1095,7 @@
Array_ (Unknown),
Array2 (Unknown) (Unknown),
Boolean_,
+ Buffer_,
Date_,
Descending (Unknown),
Either_ (Unknown) (Unknown),
@@ -2823,6 +2837,7 @@
Array1: fromUncheckedUnaryType (Array1),
Array2: fromUncheckedBinaryType (Array2),
Boolean: Boolean_,
+ Buffer: Buffer_,
Date: Date_,
ValidDate: ValidDate,
Descending: fromUncheckedUnaryType (Descending),
@@ -2974,6 +2989,7 @@
}));
+//. [Buffer]: https://nodejs.org/api/buffer.html#buffer_buffer
//. [Descending]: v:sanctuary-js/sanctuary-descending
//. [Either]: v:sanctuary-js/sanctuary-either
//. [FL:Semigroup]: https://github.com/fantasyland/fantasy-land#semigroup
diff --git a/test/index.js b/test/index.js
index be3ab32..1dff121 100644
--- a/test/index.js
+++ b/test/index.js
@@ -88,6 +88,7 @@ suite ('env', () => {
$.Array ($.Unknown),
$.Array2 ($.Unknown) ($.Unknown),
$.Boolean,
+ $.Buffer,
$.Date,
$.Descending ($.Unknown),
$.Either ($.Unknown) ($.Unknown),
@@ -1552,6 +1553,27 @@ See https://github.com/sanctuary-js/sanctuary-def/tree/v${version}#Array2 for in
eq ($.Boolean.supertypes) ([]);
});
+ test ('provides the "Buffer" type', () => {
+ eq ($.Buffer.name) ('Buffer');
+ eq ($.Buffer.url) (`https://github.com/sanctuary-js/sanctuary-def/tree/v${version}#Buffer`);
+ eq ($.Buffer.supertypes) ([]);
+
+ const isBuffer = $.test ([]) ($.Buffer);
+ eq (isBuffer (null)) (false);
+ eq (isBuffer (Buffer.from ([1, 2, 3]))) (true);
+
+ {
+ const Buffer = global.Buffer;
+ delete global.Buffer;
+ try {
+ eq (isBuffer (null)) (false);
+ eq (isBuffer (Buffer.from ([1, 2, 3]))) (false);
+ } finally {
+ global.Buffer = Buffer;
+ }
+ }
+ });
+
test ('provides the "Date" type', () => {
eq ($.Date.name) ('Date');
eq ($.Date.url) (`https://github.com/sanctuary-js/sanctuary-def/tree/v${version}#Date`);