From 3214c5004e7d3d4871cb4d60b0efd45f83294573 Mon Sep 17 00:00:00 2001 From: Adam Date: Mon, 23 Oct 2017 04:30:36 -0400 Subject: [PATCH] docs - Add helper-get-function-arity readme [skip ci] (#6532) * Add README to babel-helper-get-function-arity * Use javascript template * Address code review * Comment out ellipsis --- .../babel-helper-get-function-arity/README.md | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/packages/babel-helper-get-function-arity/README.md b/packages/babel-helper-get-function-arity/README.md index 1058da9e1e..d341c9ce35 100644 --- a/packages/babel-helper-get-function-arity/README.md +++ b/packages/babel-helper-get-function-arity/README.md @@ -1,5 +1,21 @@ # @babel/helper-get-function-arity +Function that returns the number of arguments that a function takes. +* Examples of what is considered an argument can be found at [MDN Web Docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/length) + ## Usage -TODO +```javascript +import getFunctionArity from "@babel/helper-get-function-arity"; + +function wrap(state, method, id, scope) { + // ... + if (!t.isFunction(method)) { + return false; + } + + const argumentsLength = getFunctionArity(method); + + // ... +} +```