Skip to content

Instantly share code, notes, and snippets.

@Kamisama666
Created July 20, 2017 11:23
Show Gist options
  • Save Kamisama666/240962eb61a12d1ecdedd9d0331af8dc to your computer and use it in GitHub Desktop.
Save Kamisama666/240962eb61a12d1ecdedd9d0331af8dc to your computer and use it in GitHub Desktop.
Composable function that checks if an object has a key, throws an error if not
const fn = require('fn.js');
const has = fn.curry(function(key, object) {
if (!object[key]) {
throw new Error(`Missing key '${key}' on object`);
}
return object;
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment