Coder Social home page Coder Social logo

illegal invocation about ramda HOT 4 CLOSED

sacrosanctic avatar sacrosanctic commented on June 18, 2024
illegal invocation

from ramda.

Comments (4)

semmel avatar semmel commented on June 18, 2024 1

Isn't randomUUID a function?

No, in the browser it is not a free static function, but needs to be bound to crypto:

// works in the browser — does not work in Nodejs
times(crypto.randomUUID.bind(crypto), 5);

Funnily enough, in Nodejs crypto.randomUUID is a free static function, but your example won't work there either. This is because — if called with an argument — it expects that optional argument to be an object.

You'll get another error message

TypeError: The "options" argument must be of type object. Received type number (0)

It's still an awful mess trying to write isomorphic JavaScript. (Mostly the messy browser apis imo)

Btw. same issues with console.log

😵‍💫

Supplement:
On the other hand JSON.parse again is static in the browser.

Who decides that stuff anyway, and why? It's massively annoying for FP: there seems to be no scheme.

from ramda.

sacrosanctic avatar sacrosanctic commented on June 18, 2024

Thanks for the detailed answer, I was not aware of a free static function. What kind of function is crypto.randomUUID on the browser if it is not a free static function?

from ramda.

semmel avatar semmel commented on June 18, 2024

@sacrosanctic

What kind of function is crypto.randomUUID on the browser if it is not a free static function?

A "method for the crypto namespace" perhaps?

All I know is that in C++ one calls functions which are provided by objects and operate on their (private) data "methods". In JS that would apply to functions which use this in their implementation. So perhaps randomUUID somehow needs thiscrypto to work. 🤔

from ramda.

kedashoe avatar kedashoe commented on June 18, 2024

ty for the explanation @semmel

from ramda.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.