[Pkg-javascript-commits] [pdf.js] 26/174: Add `getArray` method to `Dict`
David Prévot
taffit at moszumanska.debian.org
Thu Nov 19 18:45:02 UTC 2015
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository pdf.js.
commit 75557d27d156bac9c03417a79d12c349be478593
Author: Jonas Jenwald <jonas.jenwald at gmail.com>
Date: Mon Sep 28 14:18:11 2015 +0200
Add `getArray` method to `Dict`
This method extend `get`, and will fetch all indirect objects (i.e. `Ref`s) when the result is an `Array`.
---
src/core/obj.js | 16 ++++++++++++++++
1 file changed, 16 insertions(+)
diff --git a/src/core/obj.js b/src/core/obj.js
index 161e8ca..be62eab 100644
--- a/src/core/obj.js
+++ b/src/core/obj.js
@@ -135,6 +135,22 @@ var Dict = (function DictClosure() {
return Promise.resolve(value);
},
+ // Same as get(), but dereferences all elements if the result is an Array.
+ getArray: function Dict_getArray(key1, key2, key3) {
+ var value = this.get(key1, key2, key3);
+ if (!isArray(value)) {
+ return value;
+ }
+ value = value.slice(); // Ensure that we don't modify the Dict data.
+ for (var i = 0, ii = value.length; i < ii; i++) {
+ if (!isRef(value[i])) {
+ continue;
+ }
+ value[i] = this.xref.fetch(value[i]);
+ }
+ return value;
+ },
+
// no dereferencing
getRaw: function Dict_getRaw(key) {
return this.map[key];
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/pdf.js.git
More information about the Pkg-javascript-commits
mailing list