Skip to content

Commit db9e5c5

Browse files
committed
Merge pull request #1 from amorygalili/master
Added getKeys to networktables.js
2 parents 819c64d + 52e824f commit db9e5c5

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

docs/api_js.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ NetworkTables Interface
9393

9494
:param key: A networktables key
9595
:returns: true if a key is present in NetworkTables, false otherwise
96+
97+
.. js:function:: NetworkTables.getKeys()
98+
99+
:returns: all the keys in the NetworkTables
96100

97101
.. js:function:: NetworkTables.getValue(key[, defaultValue])
98102

pynetworktables2js/js/networktables.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ var NetworkTables = new function () {
3737
return this._[d3_map_escape(key)];
3838
};
3939

40+
this.getKeys = function() {
41+
var keys = [];
42+
for(var key in this._) keys.push(d3_map_unescape(key));
43+
return keys;
44+
};
45+
4046
this.has = function(key) {
4147
return d3_map_escape(key) in this._;
4248
};
@@ -181,6 +187,11 @@ var NetworkTables = new function () {
181187
return ntCache.has(key);
182188
};
183189

190+
// Returns all the keys in the NetworkTables
191+
this.getKeys = function() {
192+
return ntCache.getKeys();
193+
};
194+
184195
/**
185196
Returns the value that the key maps to. If the websocket is not
186197
open, this will always return the default value specified.

0 commit comments

Comments
 (0)