Skip to content

Conversation

@jhorbulyk
Copy link
Contributor

Proposed in #208

@coveralls
Copy link

Coverage Status

Coverage remained the same at 100.0% when pulling b3aea78 on elasticio:add-typeof-function into d5cbecc on jsonata-js:master.

@coveralls
Copy link

coveralls commented Oct 16, 2019

Coverage Status

Coverage remained the same at 100.0% when pulling 3bd11a8 on elasticio:add-typeof-function into d5cbecc on jsonata-js:master.

Copy link
Member

@andrew-coleman andrew-coleman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Jacob, many thanks for implementing this. Just a couple of review points... ;)

src/functions.js Outdated
Comment on lines 1862 to 1864
if(['string', 'boolean'].includes(typeof value)) {
return typeof value;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Array.includes() is an ES6 function, which means that the transpiled jsonata-es5.js will not work in ES5 environments such as IE unless we explicitly put the polyfill into polyfill.js.
However, in this case, I think it would be easier to remove this block and replace it with two if statements for the string and boolean cases.

Comment on lines 66 to 67
## `$typeOf()`
__Signature:__`$typeOf(value)`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I prefer the name $type as you proposed originally in #208. In general I favour names as single words, provided the word is a meaningful representation of what the function does. I think in this case $type would be ok?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. Most languages (e.g. JavaScript) call the operator typeof so I went with that pattern. If single word function names are preferred, we can use that.

* Rename `typeOf()` to `type()`
* Avoid use of Array.includes()
@andrew-coleman
Copy link
Member

excellent - many thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants