How to use the sanctuary-def.Any function in sanctuary-def

To help you get started, we’ve selected a few sanctuary-def examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sanctuary-js / sanctuary / test / parseJson.js View on Github external
test ('parseJson', () => {

  eq (S.show (S.parseJson)) ('parseJson :: (Any -> Boolean) -> String -> Maybe a');

  eq (S.parseJson (S.is ($.Any)) ('[Invalid JSON]')) (S.Nothing);
  eq (S.parseJson (S.is ($.Array ($.Any))) ('{"foo":"bar"}')) (S.Nothing);
  eq (S.parseJson (S.is ($.Array ($.Any))) ('["foo","bar"]')) (S.Just (['foo', 'bar']));
  eq (S.parseJson (S.is ($.Array ($.Number))) ('[1,2]')) (S.Just ([1, 2]));
  eq (S.parseJson (S.is ($.Array ($.Number))) ('[1,2,null]')) (S.Nothing);

});
github sanctuary-js / sanctuary / test / parseJson.js View on Github external
test ('parseJson', () => {

  eq (S.show (S.parseJson)) ('parseJson :: (Any -> Boolean) -> String -> Maybe a');

  eq (S.parseJson (S.is ($.Any)) ('[Invalid JSON]')) (S.Nothing);
  eq (S.parseJson (S.is ($.Array ($.Any))) ('{"foo":"bar"}')) (S.Nothing);
  eq (S.parseJson (S.is ($.Array ($.Any))) ('["foo","bar"]')) (S.Just (['foo', 'bar']));
  eq (S.parseJson (S.is ($.Array ($.Number))) ('[1,2]')) (S.Just ([1, 2]));
  eq (S.parseJson (S.is ($.Array ($.Number))) ('[1,2,null]')) (S.Nothing);

});