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
- Host: GitHub
- URL: https://github.com/aduth/wweval
- Owner: aduth
- License: mit
- Created: 2014-01-28T02:23:32.000Z (over 12 years ago)
- Default Branch: master
- Last Pushed: 2014-01-28T12:32:21.000Z (over 12 years ago)
- Last Synced: 2025-03-13T22:35:07.590Z (about 1 year ago)
- Language: JavaScript
- Size: 184 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# wweval [](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).