@hebcal/geo-sqlite 3.7.0 → 3.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! @hebcal/geo-sqlite v3.7.0 */
1
+ /*! @hebcal/geo-sqlite v3.7.1 */
2
2
  'use strict';
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
@@ -306,16 +306,21 @@ class GeoDb {
306
306
 
307
307
 
308
308
  autoComplete(qraw) {
309
+ qraw = qraw.trim();
310
+
309
311
  if (qraw.length === 0) {
310
312
  return [];
311
313
  }
312
314
 
313
- if (qraw.charCodeAt(0) >= 48 && qraw.charCodeAt(0) <= 57) {
315
+ const firstCharCode = qraw.charCodeAt(0);
316
+
317
+ if (firstCharCode >= 48 && firstCharCode <= 57) {
314
318
  if (!this.zipCompStmt) {
315
319
  this.zipCompStmt = this.zipsDb.prepare(ZIP_COMPLETE_SQL);
316
320
  }
317
321
 
318
- return this.zipCompStmt.all(qraw + '%').map(GeoDb.zipResultToObj);
322
+ const zip5 = qraw.substring(0, 5);
323
+ return this.zipCompStmt.all(zip5 + '%').map(GeoDb.zipResultToObj);
319
324
  } else {
320
325
  if (!this.geonamesCompStmt) {
321
326
  this.geonamesCompStmt = this.geonamesDb.prepare(GEONAME_COMPLETE_SQL);
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- /*! @hebcal/geo-sqlite v3.7.0 */
1
+ /*! @hebcal/geo-sqlite v3.7.1 */
2
2
  import Database from 'better-sqlite3';
3
3
  import { Location, Locale } from '@hebcal/core';
4
4
  import pino from 'pino';
@@ -294,16 +294,21 @@ class GeoDb {
294
294
 
295
295
 
296
296
  autoComplete(qraw) {
297
+ qraw = qraw.trim();
298
+
297
299
  if (qraw.length === 0) {
298
300
  return [];
299
301
  }
300
302
 
301
- if (qraw.charCodeAt(0) >= 48 && qraw.charCodeAt(0) <= 57) {
303
+ const firstCharCode = qraw.charCodeAt(0);
304
+
305
+ if (firstCharCode >= 48 && firstCharCode <= 57) {
302
306
  if (!this.zipCompStmt) {
303
307
  this.zipCompStmt = this.zipsDb.prepare(ZIP_COMPLETE_SQL);
304
308
  }
305
309
 
306
- return this.zipCompStmt.all(qraw + '%').map(GeoDb.zipResultToObj);
310
+ const zip5 = qraw.substring(0, 5);
311
+ return this.zipCompStmt.all(zip5 + '%').map(GeoDb.zipResultToObj);
307
312
  } else {
308
313
  if (!this.geonamesCompStmt) {
309
314
  this.geonamesCompStmt = this.geonamesDb.prepare(GEONAME_COMPLETE_SQL);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hebcal/geo-sqlite",
3
- "version": "3.7.0",
3
+ "version": "3.7.1",
4
4
  "author": "Michael J. Radwin (https://github.com/mjradwin)",
5
5
  "keywords": [
6
6
  "hebcal"
@@ -28,9 +28,9 @@
28
28
  "geo-sqlite.d.ts"
29
29
  ],
30
30
  "dependencies": {
31
- "@hebcal/core": "^3.32.0",
31
+ "@hebcal/core": "^3.32.1",
32
32
  "better-sqlite3": "^7.4.6",
33
- "pino": "^7.6.2",
33
+ "pino": "^7.6.3",
34
34
  "pino-pretty": "^7.3.0"
35
35
  },
36
36
  "scripts": {
@@ -62,8 +62,8 @@
62
62
  "@ava/babel": "^2.0.0",
63
63
  "@babel/core": "^7.16.7",
64
64
  "@babel/polyfill": "^7.12.1",
65
- "@babel/preset-env": "^7.16.7",
66
- "@babel/register": "^7.16.7",
65
+ "@babel/preset-env": "^7.16.8",
66
+ "@babel/register": "^7.16.8",
67
67
  "@rollup/plugin-babel": "^5.3.0",
68
68
  "@rollup/plugin-commonjs": "^21.0.1",
69
69
  "@rollup/plugin-json": "^4.1.0",