BLUE
PHP 7.4.33
Path:
/var/www/idmc.bitkit.dk/httpdocs/node_modules/generate-function
Run
Logout
Edit File
Size: 1.15 KB
Close
/var/www/idmc.bitkit.dk/httpdocs/node_modules/generate-function/test.js
Text
Base64
var tape = require('tape') var genfun = require('./') tape('generate add function', function(t) { var fn = genfun() ('function add(n) {') ('return n + %d', 42) ('}') t.same(fn.toString(), 'function add(n) {\n return n + 42\n}', 'code is indented') t.same(fn.toFunction()(10), 52, 'function works') t.end() }) tape('generate function + closed variables', function(t) { var fn = genfun() ('function add(n) {') ('return n + %d + number', 42) ('}') var notGood = fn.toFunction() var good = fn.toFunction({number:10}) try { notGood(10) t.ok(false, 'function should not work') } catch (err) { t.same(err.message, 'number is not defined', 'throws reference error') } t.same(good(11), 63, 'function with closed var works') t.end() }) tape('generate property', function(t) { var gen = genfun() t.same(gen.property('a'), 'a') t.same(gen.property('42'), '"42"') t.same(gen.property('b', 'a'), 'b.a') t.same(gen.property('b', '42'), 'b["42"]') t.same(gen.sym(42), 'tmp') t.same(gen.sym('a'), 'a') t.same(gen.sym('a'), 'a1') t.same(gen.sym(42), 'tmp1') t.same(gen.sym('const'), 'tmp2') t.end() })
Save
Close
Exit & Reset
Text mode: syntax highlighting auto-detects file type.
Directory Contents
Dirs: 0 × Files: 7
Delete Selected
Select All
Select None
Sort:
Name
Size
Modified
Enable drag-to-move
Name
Size
Perms
Modified
Actions
.travis.yml
38 B
lrw-rw-r--
2024-09-23 09:37:21
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
example.js
609 B
lrw-rw-r--
2024-09-23 09:37:21
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
index.js
3.13 KB
lrw-rw-r--
2024-09-23 09:37:21
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
LICENSE
1.05 KB
lrw-rw-r--
2024-09-23 09:37:21
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
package.json
702 B
lrw-rw-r--
2024-09-23 09:37:21
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
README.md
2.17 KB
lrw-rw-r--
2024-09-23 09:37:21
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
test.js
1.15 KB
lrw-rw-r--
2024-09-23 09:37:21
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Zip Selected
If ZipArchive is unavailable, a
.tar
will be created (no compression).