Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

664 | ref (core & schema): use string .substr method #672

Merged
merged 2 commits into from
Feb 13, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/js/core/src/algorithms/combine-paths.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const combinePaths = (a: string, b: string): string => {

// Remove any leading seperators from
while (b[0] === "/" || b[0] === ".") {
b = b.substr(1);
b = b.substring(1);
}

return a + b;
Expand Down
2 changes: 1 addition & 1 deletion packages/js/core/src/types/Uri.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ export class Uri {

// Trim preceding '/' characters
while (processed[0] === "/") {
processed = processed.substr(1);
processed = processed.substring(1);
}

// Check for the w3:// scheme, add if it isn't there
Expand Down
2 changes: 1 addition & 1 deletion packages/schema/bind/src/bindings/plugin-ts/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const toTypescript: MustacheFunction = () => {

let nullable = false;
if (type[type.length - 1] === "!") {
type = type.substr(0, type.length - 1);
type = type.substring(0, type.length - 1);
} else {
nullable = true;
}
Expand Down
10 changes: 5 additions & 5 deletions packages/schema/bind/src/bindings/wasm-as/functions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const toMsgPack: MustacheFunction = () => {

let modifier = "";
if (type[type.length - 1] === "!") {
type = type.substr(0, type.length - 1);
type = type.substring(0, type.length - 1);
} else {
modifier = "Nullable";
}
Expand All @@ -33,15 +33,15 @@ export const toWasmInit: MustacheFunction = () => {
let type = render(value);

if (type[type.length - 1] === "!") {
type = type.substr(0, type.length - 1);
type = type.substring(0, type.length - 1);
} else {
const nullType = toWasm()(value, render);
const nullable = "Nullable";
const nullOptional = "| null";

if (nullType.substr(-nullOptional.length) === nullOptional) {
if (nullType.substring(-nullOptional.length) === nullOptional) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAIK, This won't work and should be refactored with endsWith anyway.

if (nullType.endsWith(nullOptional))

return "null";
} else if (nullType.substr(0, nullable.length) === nullable) {
} else if (nullType.substring(0, nullable.length) === nullable) {
return `new ${nullType}()`;
}
}
Expand Down Expand Up @@ -87,7 +87,7 @@ export const toWasm: MustacheFunction = () => {

let nullable = false;
if (type[type.length - 1] === "!") {
type = type.substr(0, type.length - 1);
type = type.substring(0, type.length - 1);
} else {
nullable = true;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/schema/parse/src/extract/imported-types-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ export function extractImportedDefinition(
const typeName = node.name.value;

const queryIdentifier = "_Query";
const queryTest = typeName.substr(-queryIdentifier.length);
const queryTest = typeName.substring(-queryIdentifier.length);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here can be refactored with endsWith syntax

const mutationIdentifier = "_Mutation";
const mutationTest = typeName.substr(-mutationIdentifier.length);
const mutationTest = typeName.substring(-mutationIdentifier.length);

if (moduleTypes) {
// Ignore everything that isn't a query type
Expand Down