Can Ramda have isString?
Rather than have isString
, isObject
, isArray
, isFunction
, etc, Ramda simply provides is
, which you can use to create any of these you like:
const isString = R.is(String)
const isRectangle = R.is(Rectangle)
isString('foo') //=> true
isString(42) //=> false
isRectangle(new Rectangle(3, 5)) //=> true
isRectangle(new Square(7)) //=> true (if Rectangle is in the prototype chain of Square)
isRectangle(new Triangle(3, 4, 5)) //=> false
And you don't have to create the intermediate function. You can just use it as is:
R.is(String, 'foo') //=> true
R.is(String, {a: 'foo'}) //=> false