Skip to content

Commit 3bdcf0a

Browse files
Merge pull request #209 from sanctuary-js/davidchambers/types
types: define HtmlElement
2 parents 8c7ebc7 + 62d7633 commit 3bdcf0a

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

index.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,7 @@
209209

210210
var slice = Array.prototype.slice;
211211
var hasOwnProperty = Object.prototype.hasOwnProperty;
212+
var toString = Object.prototype.toString;
212213

213214
var inspect = (function() {
214215
/* istanbul ignore else */
@@ -599,6 +600,16 @@
599600
function(x) { return RegExp_._test (x) && x.global; }
600601
);
601602

603+
//# HtmlElement :: Type
604+
//.
605+
//. Type comprising every [HTML element][].
606+
var HtmlElement = NullaryTypeWithUrl (
607+
'sanctuary-def/HtmlElement',
608+
function(x) {
609+
return /^\[object HTML.+Element\]$/.test (toString.call (x));
610+
}
611+
);
612+
602613
//# Integer :: Type
603614
//.
604615
//. Type comprising every integer in the range
@@ -879,6 +890,7 @@
879890
Boolean_,
880891
Date_,
881892
Error_,
893+
HtmlElement,
882894
Null,
883895
Number_,
884896
Object_,
@@ -2615,6 +2627,7 @@
26152627
FiniteNumber: FiniteNumber,
26162628
Function: def ('Function') ({}) ([Array_ (Type), Type]) (Function_),
26172629
GlobalRegExp: GlobalRegExp,
2630+
HtmlElement: HtmlElement,
26182631
Integer: Integer,
26192632
NegativeFiniteNumber: NegativeFiniteNumber,
26202633
NegativeInteger: NegativeInteger,
@@ -2661,6 +2674,7 @@
26612674
}));
26622675

26632676
//. [FL:Semigroup]: https://github.com/fantasyland/fantasy-land#semigroup
2677+
//. [HTML element]: https://developer.mozilla.org/en-US/docs/Web/HTML/Element
26642678
//. [Monoid]: https://github.com/fantasyland/fantasy-land#monoid
26652679
//. [Setoid]: https://github.com/fantasyland/fantasy-land#setoid
26662680
//. [`Array`]: #Array

test/index.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1440,6 +1440,11 @@ See https://github.com/sanctuary-js/sanctuary-def/tree/v${version}#Array2 for in
14401440
eq (($.Function ([a, a])).url) ('');
14411441
});
14421442

1443+
test ('provides the "HtmlElement" type', () => {
1444+
eq ($.HtmlElement.name) ('sanctuary-def/HtmlElement');
1445+
eq ($.HtmlElement.url) (`https://github.com/sanctuary-js/sanctuary-def/tree/v${version}#HtmlElement`);
1446+
});
1447+
14431448
test ('provides the "NonEmpty" type constructor', () => {
14441449
eq (($.NonEmpty ($.String)).name) ('sanctuary-def/NonEmpty');
14451450
eq (($.NonEmpty ($.String)).url) (`https://github.com/sanctuary-js/sanctuary-def/tree/v${version}#NonEmpty`);

0 commit comments

Comments
 (0)