File tree Expand file tree Collapse file tree 2 files changed +12
-8
lines changed
Expand file tree Collapse file tree 2 files changed +12
-8
lines changed Original file line number Diff line number Diff line change @@ -28,7 +28,7 @@ const constants = process.binding('constants').fs;
2828const { S_IFMT , S_IFREG , S_IFLNK } = constants ;
2929const util = require ( 'util' ) ;
3030const pathModule = require ( 'path' ) ;
31- const { isUint8Array } = process . binding ( 'util' ) ;
31+ const { isUint8Array, shallowClone : copyObject } = process . binding ( 'util' ) ;
3232
3333const binding = process . binding ( 'fs' ) ;
3434const fs = exports ;
@@ -93,13 +93,6 @@ function getOptions(options, defaultOptions) {
9393 return options ;
9494}
9595
96- function copyObject ( source ) {
97- const target = { } ;
98- for ( const key in source )
99- target [ key ] = source [ key ] ;
100- return target ;
101- }
102-
10396function rethrow ( ) {
10497 // TODO(thefourtheye) Throw error instead of warning in major version > 7
10598 process . emitWarning (
Original file line number Diff line number Diff line change @@ -147,6 +147,15 @@ void WatchdogHasPendingSigint(const FunctionCallbackInfo<Value>& args) {
147147}
148148
149149
150+ void ShallowClone (const FunctionCallbackInfo<Value>& args) {
151+ if (!args[0 ]->IsObject ()) {
152+ Environment* env = Environment::GetCurrent (args);
153+ return env->ThrowTypeError (" obj must be an object" );
154+ }
155+ args.GetReturnValue ().Set (args[0 ].As <Object>()->Clone ());
156+ }
157+
158+
150159void Initialize (Local<Object> target,
151160 Local<Value> unused,
152161 Local<Context> context) {
@@ -192,6 +201,8 @@ void Initialize(Local<Object> target,
192201 env->SetMethod (target, " startSigintWatchdog" , StartSigintWatchdog);
193202 env->SetMethod (target, " stopSigintWatchdog" , StopSigintWatchdog);
194203 env->SetMethod (target, " watchdogHasPendingSigint" , WatchdogHasPendingSigint);
204+
205+ env->SetMethod (target, " shallowClone" , ShallowClone);
195206}
196207
197208} // namespace util
You can’t perform that action at this time.
0 commit comments