fogus / lemonad

a functional programming library for javascript. an experiment in elegant JS.

Home Page:http://www.functionaljs.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Let theClonusHorror handle regexps

aglundahl opened this issue · comments

theClonusHorror can't, for various reasons, clone many of the host objects in JS. It's not really a big problem, since you wouldn't expect most of them be values anyway. But when it comes to regexps, at least I expect them to behave as values. That is, it would be nice if this worked:

var hole = new L.Hole(/foo/);
L.snapshot(hole); //=> /foo/

Currently, L.snapshot(hole) would return /(?:)/, an "empty" regex, because you can't access the keys on a host object.

I guess the implementation could check if the object is an instance of RegExp and either clone it or just return it as with for example functions (which aren't values either, but who modifies a function anyway?).