GithubHelp home page GithubHelp logo

More Root Level Functions about uniter HOT 4 OPEN

asmblah avatar asmblah commented on June 18, 2024
More Root Level Functions

from uniter.

Comments (4)

asmblah avatar asmblah commented on June 18, 2024

Hi @phpengine,

Once you have an Engine instance, you can define an "auto-coercing" function like so (contrived example):

my_module.php

<?php

var_dump(my_multiply(21, 100));

index.js

var engine = require('./php/my_module.php')();

engine.defineCoercingFunction('my_multiply', function (value1, value2) {
    return value1 * value2;
});

engine.execute();

so you could use this for each function you want to define. There isn't currently a way to define a "magic" function that would be called for undefined functions, but it's something I think could come in handy so I'll look into adding that as a feature soon.

Cheers

from uniter.

phpengine avatar phpengine commented on June 18, 2024

Perfect - Thanks :)

from uniter.

yi-ge avatar yi-ge commented on June 18, 2024

defineCoercingFunction seems to be useless now.

from uniter.

asmblah avatar asmblah commented on June 18, 2024

@yi-ge apologies for not responding before; I must have missed your message. If it's still relevant could you elaborate a bit on what problem you were having with defineCoercingFunction(...) please, ie. is there a specific error you saw raised? I appreciate a lot of time has passed since though!

from uniter.

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.