An open API service indexing awesome lists of open source software.

https://github.com/aduth/wweval

Asynchronous eval using web workers
https://github.com/aduth/wweval

Last synced: about 1 year ago
JSON representation

Asynchronous eval using web workers

Awesome Lists containing this project

README

          

# wweval [![Build Status](https://travis-ci.org/aduth/wweval.png?branch=master)](https://travis-ci.org/aduth/wweval)

wweval is an asynchronous `eval` using web workers, falling back to `eval` in browsers where web workers are unsupported.

```javascript
wweval('1 + 2', function(result) {
console.log('1 + 2 = ' + result); // 3
});
```

## Usage

### Browser

Download wweval.js to your project or install using Bower (`bower install wweval`), then include the file using a `` tag.

```html
<script src="/path/to/libs/wweval.js">

wweval('1 + 2', function(result) {
console.log('1 + 2 = ' + result); // 3
});

```

### RequireJS

Download wweval.js to your project or install using Bower (`bower install wweval`), then include the file as a dependency to your module.

```javascript
define([
'path/to/libs/wweval'
], function(wweval) {
wweval('1 + 2', function(result) {
console.log('1 + 2 = ' + result); // 3
});
});
```

## Attribution

This is largely inspired by the asynchronous `eval` example on MDN ([link](https://developer.mozilla.org/en-US/docs/Web/Guide/Performance/Using_web_workers#Example_.231.3A_Create_a_generic_.22asynchronous_eval%28%29.22)), which unfortunately results in an same-origin violation error in modern browsers.

## License

Copyright 2014 Andrew Duthie.

Released freely under the MIT license (refer to LICENSE.txt).