Home / File/ utils.ts — drizzle-orm Source File

utils.ts — drizzle-orm Source File

Architecture documentation for utils.ts, a typescript file in the drizzle-orm codebase. 1 imports, 6 dependents.

File typescript DrizzleKit SchemaDiffer 1 imports 6 dependents 7 functions 1 classes

Entity Profile

Dependency Diagram

graph LR
  036f4e7e_88ec_1167_0cc5_711786d91440["utils.ts"]
  510c455f_6780_d6f0_2e8d_3babf2f068cb["camelcase"]
  036f4e7e_88ec_1167_0cc5_711786d91440 --> 510c455f_6780_d6f0_2e8d_3babf2f068cb
  5bf76609_579e_d312_b33b_ab5b8b683111["schema.ts"]
  5bf76609_579e_d312_b33b_ab5b8b683111 --> 036f4e7e_88ec_1167_0cc5_711786d91440
  ac795a29_c480_454a_c930_ea8898cad46c["introspect-gel.ts"]
  ac795a29_c480_454a_c930_ea8898cad46c --> 036f4e7e_88ec_1167_0cc5_711786d91440
  1198bdc6_ac5c_88c0_dda6_b8caf0f5d9fa["introspect-mysql.ts"]
  1198bdc6_ac5c_88c0_dda6_b8caf0f5d9fa --> 036f4e7e_88ec_1167_0cc5_711786d91440
  71516551_23e3_bf30_27c9_000fb046ef71["introspect-pg.ts"]
  71516551_23e3_bf30_27c9_000fb046ef71 --> 036f4e7e_88ec_1167_0cc5_711786d91440
  c6b71380_9588_5d06_58bb_e4dc7e505759["introspect-singlestore.ts"]
  c6b71380_9588_5d06_58bb_e4dc7e505759 --> 036f4e7e_88ec_1167_0cc5_711786d91440
  c1c349dd_2e31_d056_728c_c034cebb41c0["introspect-sqlite.ts"]
  c1c349dd_2e31_d056_728c_c034cebb41c0 --> 036f4e7e_88ec_1167_0cc5_711786d91440
  style 036f4e7e_88ec_1167_0cc5_711786d91440 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

declare global {
	interface String {
		trimChar(char: string): string;
		squashSpaces(): string;
		capitalise(): string;
		camelCase(): string;
		snake_case(): string;

		concatIf(it: string, condition: boolean): string;
	}

	interface Array<T> {
		random(): T;
	}
}

import camelcase from 'camelcase';

String.prototype.trimChar = function(char: string) {
	let start = 0;
	let end = this.length;

	while (start < end && this[start] === char) ++start;
	while (end > start && this[end - 1] === char) --end;

	// this.toString() due to ava deep equal issue with String { "value" }
	return start > 0 || end < this.length
		? this.substring(start, end)
		: this.toString();
};

String.prototype.squashSpaces = function() {
	return this.replace(/  +/g, ' ').trim();
};

String.prototype.camelCase = function() {
	return camelcase(String(this));
};

String.prototype.capitalise = function() {
	return this && this.length > 0
		? `${this[0].toUpperCase()}${this.slice(1)}`
		: String(this);
};

String.prototype.concatIf = function(it: string, condition: boolean) {
	return condition ? `${this}${it}` : String(this);
};

String.prototype.snake_case = function() {
	return this && this.length > 0 ? `${this.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`)}` : String(this);
};

Array.prototype.random = function() {
	return this[~~(Math.random() * this.length)];
};

export {};

Domain

Subdomains

Classes

Types

Dependencies

  • camelcase

Frequently Asked Questions

What does utils.ts do?
utils.ts is a source file in the drizzle-orm codebase, written in typescript. It belongs to the DrizzleKit domain, SchemaDiffer subdomain.
What functions are defined in utils.ts?
utils.ts defines 7 function(s): camelCase, capitalise, concatIf, random, snake_case, squashSpaces, trimChar.
What does utils.ts depend on?
utils.ts imports 1 module(s): camelcase.
What files import utils.ts?
utils.ts is imported by 6 file(s): introspect-gel.ts, introspect-mysql.ts, introspect-pg.ts, introspect-singlestore.ts, introspect-sqlite.ts, schema.ts.
Where is utils.ts in the architecture?
utils.ts is located at drizzle-kit/src/@types/utils.ts (domain: DrizzleKit, subdomain: SchemaDiffer, directory: drizzle-kit/src/@types).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free