public JsStream(IronJS.Environment env, Stream stream) : base(env, env.NewPrototype()) { Put("read", IronJS.Native.Utils.CreateFunction<Func<CommonObject>>(env, 0, () => { if (stream == null) { return null; } string input; using (var strm = stream) { strm.Position = 0; var reader = new StreamReader(strm); input = reader.ReadToEnd(); strm.Close(); } return env.NewString(input); })); }