Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

inspect( 1n ) => no joy #40

Closed
loveencounterflow opened this issue Mar 1, 2021 · 2 comments · Fixed by #41
Closed

inspect( 1n ) => no joy #40

loveencounterflow opened this issue Mar 1, 2021 · 2 comments · Fixed by #41
Labels

Comments

@loveencounterflow
Copy link

loveencounterflow commented Mar 1, 2021

Title says it all.

I tried to fix it and jeez you guys should clean up your code.

There's a serious systematic fault here at play in that execution for unknown types will hit if ( 'constructor' in value ) around line 1161 which causes an exception e.g. with bigints. Fix is of course to add that one to the list of known types, but this won't prevent an exception for any new types that get added to JS. For what it does (and it worked well for me so far) the code is much too convoluted IMHO. Also unnecessarily 'abstracty' where abstraction doesn't buy you anything. Case in point, you return fancy formatting handlers for undefined, null, true, false, when the representations for these values are just these very strings and you're done. All types have aliases with lower and upper case. Type checking is wrapped inside a CSJS polyfill. There is a section dedicated to HTMLTableHeaderCellElement. Wat, seriously. Some code meant to be used by Chai objects only is thrown in, in no meaningful way separated from the general-purpose stuff (this almost made me toss loupe altogether).

Here I donate you some code:

domenic_denicola_device  = ( x ) -> x?.constructor?.name ? './.'
mark_miller_device       = ( x ) -> ( Object::toString.call x ).slice 8, -1
# mark_miller_device       = ( x ) -> ( ( Object::toString.call x ).slice 8, -1 ).toLowerCase().replace /\s+/g, ''
js_type_of   = ( x ) -> ( ( Object::toString.call x ).slice 8, -1 ).toLowerCase().replace /\s+/g, ''

IMO these are good starts to radically simplify the type checking stuff. Have fun.

loveencounterflow pushed a commit to loveencounterflow/intertype that referenced this issue Mar 1, 2021
@loveencounterflow
Copy link
Author

loveencounterflow commented Mar 1, 2021

Update the below repeated as #42

Also, dependency https://github.com/sorensen/get-function-name.js is broken; it apparently results in these lines in the build:

	var getFunctionName = function(fn) {
	  if (toString$1.call(fn) !== '[object Function]') return null
	  if (fn.name) return fn.name
	  var name = /^\s*function\s*([^\(]*)/im.exec(fn.toString())[1];
	  return name || 'anonymous'
	};

This code does not deal with anonymous arrow function and does not even honor the fact that the RegExp::exec() method may return null on mismatch. Apart from that, the code above is fairly convoluted for what it does.

@github-actions
Copy link

github-actions bot commented Mar 1, 2021

🎉 This issue has been resolved in version 2.1.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant