Snapshot của eligrey/jsandbox: 199★ · JavaScript. A JavaScript sandboxing library that uses web worker threads
Tóm tắt dựng từ metadata GitHub của chính dự án — chưa có bài review TopGit. Trang sẽ tự động cập nhật khi bài review đầy đủ được xuất bản.
VÌ SAO CHƯA CÓ REVIEW
TopGit viết bài đầy đủ cho repo có nhiều sao nhất và được yêu cầu nhiều nhất. Trang này là snapshot trong thời gian chờ — xem README gốc ở tab READ ME.
JSandbox is an open source JavaScript
sandboxing library that makes use of HTML5 web workers. JSandbox makes it possible to run
untrusted JavaScript without having to worry about any potential dangers.
Getting Started
Download JSandbox.
Include <link rel="jsandbox" href="path/to/jsandbox-worker.js" /> anywhere in your
document. I recommend putting it in the document's <head>.
Place <script type="text/javascript" src="path/to/jsandbox.js"></script>
anywhere after the <link> tag.
Read the API documentation below.
Example Code
This example code demonstrates the JSandbox API.
Tested Working Browsers
Firefox 3.5+
Google Chrome 4+
API
Worker script location
Instead of using a <link> tag, you may define JSandbox.url to specify the location
of the JSandbox worker script.
Methods
All of these methods can be accessed on the JSandbox constructor (in one-use sandboxes)
and JSandbox instances:
eval(options)
eval()s options.data. If options.callback is a
function, it is passed the results as long as no errors occur. If
options.onerror is a function and an error occurs, it is passed the error
object. The code is eval()ed in a top-level pseudo-function-scope. If you
define a variable using a var statement, the variable is private to the
eval. this is still the global object. If this method is called on
JSandbox, the JSandbox object is returned. Otherwise, the ID
of the request is returned.
exec(options)
Executes code in a faster method than eval, but does not pass a
return value to the callback function (though the function is still called if
defined). Unlike eval, the code is run in the global scope
(var statements affect this).
load(options)
If options.data is a string, options.data will attempt to be
loaded in the sandbox. If options.data is an array, every string it
contains will attempt be loaded. If options.onerror is a function and an
error is thrown while parsing a script or a script could not be resolved,
options.onerror is passed the error object. Otherwise,
options.callback is called when the scripts are finished loading.
Instance-only methods
These methods can only be on JSandbox instances:
abort(requestID)
Aborts a pending request with the ID, requestID.
terminate()
Terminates the worker thread and any pending requests are aborted. You cannot use the
JSandbox instance on which you called this method after it is called.
options object
The following are all of the properties that may be included in an options object.
data [Required]
In the case of eval and exec, it is the code to execute. In
the case of load, it is an array of the script(s) to load. If you only
need to load one script, just pass a string instead.
input
The input data available to the code via the input variable. The input should be
JSON-convertible.
callback
The callback to pass the return value of the executed code if no exceptions were
thrown.
onerror
The callback to pass an exception if one is thrown upon executing the code.
Alternative syntax
Any method that takes an options object can also be called using the following
positional-arguments syntax:
Trang TopGit này là một snapshot — tab "Readme" hiển thị nguyên văn README của repo (đã bỏ link, giữ ảnh). Repo GitHub ở github.com/eligrey/jsandbox là nguồn chính thức.
eligrey/jsandbox có phải mã nguồn mở không?
TopGit chưa ghi nhận license cho eligrey/jsandbox. Phần lớn repo public trên GitHub là mã nguồn mở, nhưng điều khoản khác nhau từng repo — mở file LICENSE để xác nhận.
eligrey/jsandbox có tag gì không?
Bản đồng bộ chưa ghi nhận topic GitHub nào cho eligrey/jsandbox. GitHub topics hiển thị ở thanh bên phải trang repo — đó là nơi đáng kiểm tra nhất.
eligrey/jsandbox có website riêng không?
TopGit chưa ghi nhận URL trang chủ cho eligrey/jsandbox. Phần README ở tab phía trên thường có link demo, hoặc xem mô tả GitHub của repo.
eligrey/jsandbox còn đang phát triển không?
Commit gần nhất trên eligrey/jsandbox là 8.6 năm trước (theo timestamp GitHub). Repo có 13 fork — một chỉ báo về mức độ quan tâm của cộng đồng.
Đọc đầy đủ README ở tab phía trên.
Vẫn đang phân vân về jsandbox?
Một cú bấm sẽ gửi câu hỏi kèm trang này cho AI — xem AI nói gì về jsandbox.