我正在尝试让nodeunit模块在coffeescript项目中运行,但似乎无法运行基本测试.这是我的例子Coffeescript要求'nodeunit'
test = true
test2 = false
exports.testSomething = (test) ->
test.expect(1)
test.ok(true, "this should pass")
test.done()
exports.testSomethingElse = (test2) ->
test2.expect(1)
test2.ok(false, "this should fail")
test2.done()
Run Code Online (Sandbox Code Playgroud)
不幸的是,当我运行'$ nodeunit example.coffee'时,我收到错误输出:
example.coffee:4 exports.testSomething =(test) - > ^
module.js:296 throw err; ^ SyntaxError:在Function._load上的Module.load(module.js:334:31)处的Object..js(module.js:408:10)处的Module._compile(module.js:397:25)处的意外的令牌> (module.js:293:12)在/ usr/local/lib/node的/usr/local/lib/node/nodeunit/lib/nodeunit.js:75:37上的require(module.js:346:19) /nodeunit/deps/async.js:508:13 /usr/local/lib/node/nodeunit/deps/async.js:118:13 /usr/local/lib/node/nodeunit/deps/async.js :134:9 /usr/local/lib/node/nodeunit/deps/async.js:507:9
任何人都可以帮助我使用Node.js在Coffeescript中进行简化测试并运行吗?
提前致谢
我正在使用PHP从SOAP服务中检索数据,该服务的一部分是用base64编码的图像的字节数组,我想在浏览器中显示该图像。数据检索步骤工作正常,但是我找不到在浏览器中显示此图像的单一方法。
假设字节数组在PHP中以$ byteArray存储:
$img = "<img src= 'data:image/jpeg;base64, $byteArray' />";
print($img);
Run Code Online (Sandbox Code Playgroud)
我希望该代码在浏览器中显示图像,但是浏览器的解析器始终会失败。知道我在做什么错吗?
我在这里使用的一个示例byteArray是:“ [B @ 14a3da8”
预先感谢,Brian