Skip to content

Commit b9fdfc3

Browse files
committed
add set()
1 parent 4adc65a commit b9fdfc3

3 files changed

Lines changed: 21 additions & 1 deletion

File tree

lib/node/node-wsh.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,18 @@ class Proxies {
8686
default: throw new Error( `unknown status: ${ output[ 0]}`);
8787
}
8888
},
89+
90+
set( target, prop, value) {
91+
const encodedTarget = this.proxies.#encode( target[ PROXY]);
92+
const encodedProp = this.proxies.#encode( prop);
93+
const encodedValue = this.proxies.#encode( value);
94+
const output = JSON.parse( this.proxies.#syncline.exchange( JSON.stringify( [ 'set', encodedTarget, encodedProp, encodedValue])));
95+
switch( output[ 0]) {
96+
case 'set': return;
97+
case 'error': throw new Error( output[ 1]);
98+
default: throw new Error( `unknown status: ${ output[ 0]}`);
99+
}
100+
},
89101
};
90102

91103
#functionHandler = {

lib/wsh/host.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ function decodePotentialMethod( encoded) {
138138
var output;
139139
var target;
140140
var prop;
141+
var value;
141142
var thisArg;
142143
var args;
143144
while( !WScript.StdIn.AtEndOfLine)
@@ -162,6 +163,13 @@ function decodePotentialMethod( encoded) {
162163
output = [ 'value', encodePotentialMethod( target, prop)];
163164
}
164165
break;
166+
case 'set': // [ 'set', target, prop, value] => [ 'set']
167+
target = decode( input[ 1]);
168+
prop = decode( input[ 2]);
169+
value = decode( input[ 3]);
170+
target[ prop] = value;
171+
output = [ 'set'];
172+
break;
165173
case 'apply': // [ 'apply', target, thisArg, argumentList] => [ 'value', value]
166174
target = decodePotentialMethod( input[ 1]);
167175
thisArg = decode( input[ 2]);

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@arcticnotes/node-wsh",
3-
"version": "0.0.8",
3+
"version": "0.0.9",
44
"description": "A Node.js package that runs Windows Scripting Host (WSH) as a child process and exposes the resources from the WSH world to the Node.js world",
55
"author": "Paul <paul@arcticnotes.com>",
66
"license": "MIT",

0 commit comments

Comments
 (0)