Skip to content

Commit 0c12af9

Browse files
Merge pull request #52 from Keillion/master
update README.md
2 parents 8918e1f + 4ebe817 commit 0c12af9

File tree

3 files changed

+35
-17
lines changed

3 files changed

+35
-17
lines changed

README.md

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -266,16 +266,25 @@ The library is based on the `WebAssembly` standard, therefore, **on first use**,
266266

267267
`Dynamsoft.BarcodeReader.loadWasm` is the API to start the initialization.
268268

269-
```javascript
270-
Dynamsoft.BarcodeReader.loadWasm()
271-
.then(()=>{ /* success */ }, ex=>{console.error(ex.message||ex);})
269+
```js
270+
try{
271+
await Dynamsoft.BarcodeReader.loadWasm();
272+
}catch(ex){
273+
console.error(ex);
274+
}
272275
```
273276

274277
That said, as shown in the sample above, you don't necessarily need to call the above API because other APIs like `Dynamsoft.BarcodeReader.createInstance` and `Dynamsoft.BarcodeScanner.createInstance` will call `loadWasm` themselves.
275278

276-
```javascript
277-
Dynamsoft.BarcodeReader.createInstance()
278-
.then(reader=>{ /* success */ }, ex=>{console.error(ex.message||ex);})
279+
```js
280+
let reader = null;
281+
let scanner = null;
282+
try{
283+
reader = await Dynamsoft.BarcodeReader.createInstance();
284+
scanner = await Dynamsoft.BarcodeScanner.createInstance();
285+
}catch(ex){
286+
console.error(ex);
287+
}
279288
```
280289

281290
> **NOTE**: Including the library with a script tag doesn't automatically initialize the library. For better performance, you may want to call `loadWasm` to download and compile the `wasm` file in advance and create a reader or scanner instance later.
@@ -542,7 +551,7 @@ let scanner = null;
542551
To speed up the scanning process, you can choose to scan only a specific area/region.
543552

544553
```javascript
545-
let settings = await barcodeScanner.getRuntimeSettings();
554+
let settings = await scanner.getRuntimeSettings();
546555
/*
547556
* 1 means true
548557
* Using a percentage is easier

doc/api reference/index.html

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -408,11 +408,20 @@ <h3>Initializing</h3>
408408
</a>
409409
<p>The library is based on the <code>WebAssembly</code> standard, therefore, <strong>on first use</strong>, it needs some time to download and compile the <code>wasm</code> files. After the first use, the browser may cache the file so that the next time no &#39;downloading&#39; is required.</p>
410410
<p><code>Dynamsoft.BarcodeReader.loadWasm</code> is the API to start the initialization. </p>
411-
<pre><code class="language-javascript">Dynamsoft.BarcodeReader.loadWasm()
412-
.then(<span class="hljs-function"><span class="hljs-params">()</span>=&gt;</span>{ <span class="hljs-comment">/* success */</span> }, ex=&gt;{<span class="hljs-built_in">console</span>.error(ex.message||ex);})</code></pre>
411+
<pre><code class="language-js"><span class="hljs-keyword">try</span>{
412+
<span class="hljs-keyword">await</span> Dynamsoft.BarcodeReader.loadWasm();
413+
}<span class="hljs-keyword">catch</span>(ex){
414+
<span class="hljs-built_in">console</span>.error(ex);
415+
}</code></pre>
413416
<p>That said, as shown in the sample above, you don&#39;t necessarily need to call the above API because other APIs like <code>Dynamsoft.BarcodeReader.createInstance</code> and <code>Dynamsoft.BarcodeScanner.createInstance</code> will call <code>loadWasm</code> themselves.</p>
414-
<pre><code class="language-javascript">Dynamsoft.BarcodeReader.createInstance()
415-
.then(<span class="hljs-function"><span class="hljs-params">reader</span>=&gt;</span>{ <span class="hljs-comment">/* success */</span> }, ex=&gt;{<span class="hljs-built_in">console</span>.error(ex.message||ex);})</code></pre>
417+
<pre><code class="language-js"><span class="hljs-keyword">let</span> reader = <span class="hljs-literal">null</span>;
418+
<span class="hljs-keyword">let</span> scanner = <span class="hljs-literal">null</span>;
419+
<span class="hljs-keyword">try</span>{
420+
reader = <span class="hljs-keyword">await</span> Dynamsoft.BarcodeReader.createInstance();
421+
scanner = <span class="hljs-keyword">await</span> Dynamsoft.BarcodeScanner.createInstance();
422+
}<span class="hljs-keyword">catch</span>(ex){
423+
<span class="hljs-built_in">console</span>.error(ex);
424+
}</code></pre>
416425
<blockquote>
417426
<p><strong>NOTE</strong>: Including the library with a script tag doesn&#39;t automatically initialize the library. For better performance, you may want to call <code>loadWasm</code> to download and compile the <code>wasm</code> file in advance and create a reader or scanner instance later.</p>
418427
</blockquote>
@@ -640,7 +649,7 @@ <h3>Show found barcodes</h3>
640649
<h3>Read a specific area/region</h3>
641650
</a>
642651
<p>To speed up the scanning process, you can choose to scan only a specific area/region.</p>
643-
<pre><code class="language-javascript"><span class="hljs-keyword">let</span> settings = <span class="hljs-keyword">await</span> barcodeScanner.getRuntimeSettings();
652+
<pre><code class="language-javascript"><span class="hljs-keyword">let</span> settings = <span class="hljs-keyword">await</span> scanner.getRuntimeSettings();
644653
<span class="hljs-comment">/*
645654
* 1 means true
646655
* Using a percentage is easier
@@ -737,7 +746,7 @@ <h2>License Agreement</h2>
737746
<a href="#contact-us" id="contact-us" style="color: inherit; text-decoration: none;">
738747
<h2>Contact Us</h2>
739748
</a>
740-
<p>If there are any questions, please feel free to contact <a href="mailto:&#x73;&#x75;&#x70;&#x70;&#x6f;&#114;&#116;&#64;&#x64;&#121;&#110;&#97;&#x6d;&#115;&#x6f;&#x66;&#116;&#x2e;&#x63;&#111;&#x6d;">&#x73;&#x75;&#x70;&#x70;&#x6f;&#114;&#116;&#64;&#x64;&#121;&#110;&#97;&#x6d;&#115;&#x6f;&#x66;&#116;&#x2e;&#x63;&#111;&#x6d;</a>.</p>
749+
<p>If there are any questions, please feel free to contact <a href="mailto:&#115;&#117;&#x70;&#x70;&#111;&#114;&#x74;&#x40;&#x64;&#121;&#110;&#97;&#x6d;&#115;&#x6f;&#102;&#x74;&#x2e;&#99;&#111;&#x6d;">&#115;&#117;&#x70;&#x70;&#111;&#114;&#x74;&#x40;&#x64;&#121;&#110;&#97;&#x6d;&#115;&#x6f;&#102;&#x74;&#x2e;&#99;&#111;&#x6d;</a>.</p>
741750
</div>
742751
</div>
743752
<div class="col-4 col-menu menu-sticky-wrap menu-highlight">

doc/api reference/interfaces/barcodereaderexception.html

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ <h3>Error</h3>
100100
<div class="tsd-signature tsd-kind-icon">Error<span class="tsd-signature-symbol">:</span> <span class="tsd-signature-type">ErrorConstructor</span></div>
101101
<aside class="tsd-sources">
102102
<ul>
103-
<li>Defined in D:/workfoler/tfs24/Default/DBR/DBR_WASM_7.2/node_modules/typedoc/node_modules/typescript/lib/lib.es5.d.ts:984</li>
103+
<li>Defined in D:/workfoler/tfs24/Default/DBR/DBR_WASM/node_modules/typedoc/node_modules/typescript/lib/lib.es5.d.ts:984</li>
104104
</ul>
105105
</aside>
106106
</section>
@@ -121,7 +121,7 @@ <h3>message</h3>
121121
<aside class="tsd-sources">
122122
<p>Inherited from Error.message</p>
123123
<ul>
124-
<li>Defined in D:/workfoler/tfs24/Default/DBR/DBR_WASM_7.2/node_modules/typedoc/node_modules/typescript/lib/lib.es5.d.ts:974</li>
124+
<li>Defined in D:/workfoler/tfs24/Default/DBR/DBR_WASM/node_modules/typedoc/node_modules/typescript/lib/lib.es5.d.ts:974</li>
125125
</ul>
126126
</aside>
127127
</section>
@@ -132,7 +132,7 @@ <h3>name</h3>
132132
<aside class="tsd-sources">
133133
<p>Inherited from Error.name</p>
134134
<ul>
135-
<li>Defined in D:/workfoler/tfs24/Default/DBR/DBR_WASM_7.2/node_modules/typedoc/node_modules/typescript/lib/lib.es5.d.ts:973</li>
135+
<li>Defined in D:/workfoler/tfs24/Default/DBR/DBR_WASM/node_modules/typedoc/node_modules/typescript/lib/lib.es5.d.ts:973</li>
136136
</ul>
137137
</aside>
138138
</section>
@@ -144,7 +144,7 @@ <h3><span class="tsd-flag ts-flagOptional">Optional</span> stack</h3>
144144
<p>Inherited from Error.stack</p>
145145
<p>Overrides Error.stack</p>
146146
<ul>
147-
<li>Defined in D:/workfoler/tfs24/Default/DBR/DBR_WASM_7.2/node_modules/typedoc/node_modules/typescript/lib/lib.es5.d.ts:975</li>
147+
<li>Defined in D:/workfoler/tfs24/Default/DBR/DBR_WASM/node_modules/typedoc/node_modules/typescript/lib/lib.es5.d.ts:975</li>
148148
</ul>
149149
</aside>
150150
</section>

0 commit comments

Comments
 (0)