Giter VIP home page Giter VIP logo

javascriptcore.cr's Introduction

JavaScriptCore.cr logo

JavaScriptCore.cr

JavaScriptCore bindings for Crystal


Code Of Conduct BSD-2-Clause Licensed ci action status

What is this?

JavaScriptCore is a framework that provides a JavaScript engine for WebKit implementations, and provides this type of scripting in other contexts within macOS. JavaScriptCore is originally derived from KDE's JavaScript engine (KJS) library (which is part of the KDE project) and the PCRE regular expression library. Since forking from KJS and PCRE, JavaScriptCore has been improved with many new features and greatly improved performance.

from: https://en.wikipedia.org/wiki/WebKit#JavaScriptCore

This shard provides bindings for it, allowing you to evaluate JS from Crystal!

Bindings are being generated using gi-crystal.

Dependencies

You need JavaScriptCore 5.0. Your distro might provide it as libjavascriptcoregtk-5_0 or typelib-1_0-JavaScriptCore-5_0. If it doesn't then try installing webkit2gtk (the latest, -dev or -devel version if available). Doc generation will probably only be availble by installing one of the webkit2gtk packages.

Installation

  1. Add the dependency to your shard.yml:

    dependencies:
      javascriptcore:
        github: GeopJr/JavaScriptCore.cr
  2. Run shards install

  3. Run ./bin/gi-crystal to generate the bindings

Usage

There's a lot you can do with the bindings, but here's a simple evaluation:

require "javascriptcore"

context = JavaScriptCore::Context.new
script = "['Java', 'Script', 'Core'].join('')"
result = context.evaluate(script, -1)

p result.to_s #=> "JavaScriptCore"

There might be more examples on ./spec.

Contributing

  1. Read the Code of Conduct
  2. Fork it ( https://github.com/GeopJr/JavaScriptCore.cr/fork )
  3. Create your feature branch (git checkout -b my-new-feature)
  4. Commit your changes (git commit -am 'Add some feature')
  5. Push to the branch (git push origin my-new-feature)
  6. Create a new Pull Request

javascriptcore.cr's People

Contributors

geopjr avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

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.