Browse Source

moved toUpperCase to string.ts

Alexander Rose 5 years ago
parent
commit
cd23a68268
3 changed files with 9 additions and 12 deletions
  1. 2 2
      src/mol-script/runtime/query/table.ts
  2. 7 0
      src/mol-util/string.ts
  3. 0 10
      src/mol-util/upper-case.ts

+ 2 - 2
src/mol-script/runtime/query/table.ts

@@ -10,7 +10,7 @@ import { DefaultQueryRuntimeTable, QuerySymbolRuntime, QueryRuntimeArguments } f
 import { Queries, StructureProperties, StructureElement, QueryContext, UnitRing } from '../../../mol-model/structure';
 import { ElementSymbol, LinkType } from '../../../mol-model/structure/model/types';
 import { SetUtils } from '../../../mol-util/set';
-import toUpperCase from '../../../mol-util/upper-case';
+import { upperCaseAny } from '../../../mol-util/string';
 import { VdwRadius, AtomWeight, AtomNumber } from '../../../mol-model/structure/model/properties/atomic';
 import { cantorPairing } from '../../../mol-data/util';
 import C = QuerySymbolRuntime.Const
@@ -174,7 +174,7 @@ const symbols = [
 
     // ============= TYPES ================
     C(MolScript.structureQuery.type.elementSymbol, (ctx, v) => ElementSymbol(v[0](ctx))),
-    C(MolScript.structureQuery.type.atomName, (ctx, v) => toUpperCase(v[0](ctx))),
+    C(MolScript.structureQuery.type.atomName, (ctx, v) => upperCaseAny(v[0](ctx))),
     C(MolScript.structureQuery.type.linkFlags, (ctx, xs) => {
         let ret: LinkType = LinkType.Flag.None;
         if (typeof xs.length === 'number') {

+ 7 - 0
src/mol-util/string.ts

@@ -2,6 +2,7 @@
  * Copyright (c) 2018-2019 mol* contributors, licensed under MIT, See LICENSE file for more info.
  *
  * @author Alexander Rose <alexander.rose@weirdbyte.de>
+ * @author David Sehnal <david.sehnal@gmail.com>
  */
 
 const reLine = /^/mg
@@ -22,6 +23,12 @@ export function camelCaseToWords(str: string) {
 export const lowerCase = (str: string) => str.toLowerCase()
 export const upperCase = (str: string) => str.toUpperCase()
 
+/** Return upper case if string, otherwise return empty string */
+export function upperCaseAny(value: any): string {
+    if (!value) return '';
+    return typeof value === 'string' ? value.toUpperCase() : `${value}`.toUpperCase();
+}
+
 /** Uppercase the first character of each word. */
 export function capitalize(str: string) {
     return str.toLowerCase().replace(/^\w|\s\w/g, upperCase);

+ 0 - 10
src/mol-util/upper-case.ts

@@ -1,10 +0,0 @@
-/**
- * Copyright (c) 2018 mol* contributors, licensed under MIT, See LICENSE file for more info.
- *
- * @author David Sehnal <david.sehnal@gmail.com>
- */
-
-export default function toUpperCase(value: any): string {
-    if (!value) return '';
-    return typeof value === 'string' ? value.toUpperCase() : `${value}`.toUpperCase();
-}