Skip to content

Commit

Permalink
Update to winreg 1.2.0 (DefinitelyTyped#9157)
Browse files Browse the repository at this point in the history
* Update to winreg 1.2.0

* Used @link for jsdoc on WinregStatic constructor. Updated jsdoc on Options.arch.
  • Loading branch information
BobBuehler authored and vvakame committed May 5, 2016
1 parent 9143f12 commit e1860b0
Show file tree
Hide file tree
Showing 2 changed files with 250 additions and 132 deletions.
93 changes: 69 additions & 24 deletions winreg/winreg-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ var regKey3 = new Winreg({
})

var str: string = regKey.parent.key
var par: Winreg = regKey.parent
var par: Winreg.Registry = regKey.parent

regKey.values((err, items) => {
var itemsC: Array<Winreg.RegistryItem> = items;
Expand All @@ -28,11 +28,11 @@ regKey.values((err, items) => {
});

regKey.keys((err, items) => {
var itemsC: Array<Winreg> = items;
var itemsC: Array<Winreg.Registry> = items;
var errorC: Error = err;

items.forEach((item) => {
var regKey4: Winreg = item;
var regKey4: Winreg.Registry = item;
});
});

Expand All @@ -47,49 +47,94 @@ var r2 = new Winreg({
hive: Winreg.HKCU,
key: '\\Control Panel\\Desktop'
})
var r3 = new Winreg({
host: 'blah',
arch: 'x64'
})

// get parent key
console.log('parent of "'+r2.path+'" -> "'+r2.parent.path+'"');

// list subkeys
r2.keys(function (err, items) {
// list values
r1.values(function (err, items) {

if (!err) {
for (var i = 0, l = items.length; i < l; i++) {
console.log('subkey of "'+r2.path+'": '+items[i].path);
}
console.log(JSON.stringify(items, null, '\t'));
}

// list values
r1.values(function (err, items) {
// query named value
r1.get(items[0].name, function (err, item) {

if (!err) {
console.log(JSON.stringify(items, null, '\t'));
console.log(JSON.stringify(item, null, '\t'));
}

// query named value
r1.get(items[0].name, function (err, item) {
// add value
r1.set('bla', Winreg.REG_SZ, 'hello world!', function (err) {

if (!err) {
console.log(JSON.stringify(item, null, '\t'));
console.log('value written');
}

// add value
r1.set('bla', Winreg.REG_SZ, 'hello world!', function (err) {
// delete value
r1.remove('bla', function (err) {

if (!err) {
console.log('value written');
console.log('value deleted');
}

// delete value
r1.remove('bla', function (err) {
});
});
});
});

if (!err) {
console.log('value deleted');
}
// check for key
r2.keyExists(function (err, exists) {

if (!err) {
if (exists) {
console.log('key ' + r2.key + ' exists');
} else {

console.log('key ' + r2.key + ' does not exist');
}
}

// check for value
r2.valueExists('bla', function (err, exists) {

if (!err) {
if (exists) {
console.log('value bla exists on key ' + r2.key);
} else {
console.log('value bla does not exist on key ' + r2.key);
}
}

});
});

// create new key or no-op
r3.create(function (err) {

if (!err) {
console.log('key created');
}

// clear subkeys of key and values on key
r3.clear(function (err) {

if (!err) {
console.log('key cleared');
}

// remove this key and all its subkeys
r3.destroy(function (err) {

if (!err) {
console.log('key destroyed');
}

});
});
});
});
});
Loading

0 comments on commit e1860b0

Please sign in to comment.