diff options
Diffstat (limited to 'src/stream_base-inl.h')
-rw-r--r-- | src/stream_base-inl.h | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/stream_base-inl.h b/src/stream_base-inl.h index 81114a265e..099e105334 100644 --- a/src/stream_base-inl.h +++ b/src/stream_base-inl.h @@ -43,6 +43,13 @@ void StreamBase::AddMethods(Environment* env, v8::DEFAULT, attributes); + t->InstanceTemplate()->SetAccessor(env->bytes_read_string(), + GetBytesRead<Base>, + nullptr, + env->as_external(), + v8::DEFAULT, + attributes); + env->SetProtoMethod(t, "readStart", JSMethod<Base, &StreamBase::ReadStart>); env->SetProtoMethod(t, "readStop", JSMethod<Base, &StreamBase::ReadStop>); if ((flags & kFlagNoShutdown) == 0) @@ -80,6 +87,16 @@ void StreamBase::GetFD(Local<String> key, template <class Base> +void StreamBase::GetBytesRead(Local<String> key, + const PropertyCallbackInfo<Value>& args) { + StreamBase* wrap = Unwrap<Base>(args.Holder()); + + // uint64_t -> double. 53bits is enough for all real cases. + args.GetReturnValue().Set(static_cast<double>(wrap->bytes_read_)); +} + + +template <class Base> void StreamBase::GetExternal(Local<String> key, const PropertyCallbackInfo<Value>& args) { StreamBase* wrap = Unwrap<Base>(args.Holder()); |