Skip to content

Commit

Permalink
chore: attempted build
Browse files Browse the repository at this point in the history
  • Loading branch information
shadowtime2000 committed Oct 10, 2020
1 parent ba6c9ec commit cc47951
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 18 deletions.
2 changes: 1 addition & 1 deletion deno_dist/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@ export { templates } from "./containers.ts";
export {
config,
config as defaultConfig,
getConfig,
configure,
getConfig,
} from "./config.ts";
4 changes: 2 additions & 2 deletions deno_dist/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,8 +170,8 @@ function getConfig(override: PartialConfig, baseConfig?: EtaConfig): EtaConfig {

/** Update Eta's base config */

function configure(options: PartialConfig) {
function configure(options: PartialConfig): Partial<EtaConfig> {
return copyProps(config, options);
}

export { config, getConfig, configure };
export { config, configure, getConfig };
2 changes: 1 addition & 1 deletion deno_dist/err.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ EtaErr.prototype = Object.create(Error.prototype, {
* Throws an EtaErr with a nicely formatted error and message showing where in the template the error occurred.
*/

export function ParseErr(message: string, str: string, indx: number) {
export function ParseErr(message: string, str: string, indx: number): void {
var whitespace = str.slice(0, indx).split(/\n/);

var lineNo = whitespace.length;
Expand Down
12 changes: 8 additions & 4 deletions deno_dist/file-handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ import { promiseImpl } from "./polyfills.ts";

import type {
EtaConfig,
PartialConfig,
EtaConfigWithFilename,
PartialConfig,
} from "./config.ts";
import type { TemplateFunction } from "./compile.ts";

Expand Down Expand Up @@ -193,16 +193,20 @@ function renderFile(
data: DataObj,
config?: PartialConfig,
cb?: CallbackFn,
): any;
): (Promise<string> | void);

function renderFile(filename: string, data: DataObj, cb?: CallbackFn): any;
function renderFile(
filename: string,
data: DataObj,
cb?: CallbackFn,
): (Promise<string> | void);

function renderFile(
filename: string,
data: DataObj,
config?: PartialConfig,
cb?: CallbackFn,
) {
): (Promise<string> | void) {
/*
Here we have some function overloading.
Essentially, the first 2 arguments to renderFile should always be the filename and data
Expand Down
4 changes: 2 additions & 2 deletions deno_dist/file-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function getWholeFilePath(
* @return absolute path to template
*/

function getPath(path: string, options: EtaConfig) {
function getPath(path: string, options: EtaConfig): string {
var includePath: string | false = false;
var views = options.views;
var searchedPaths: Array<string> = [];
Expand Down Expand Up @@ -192,7 +192,7 @@ function getPath(path: string, options: EtaConfig) {
* Reads a file synchronously
*/

function readFile(filePath: string) {
function readFile(filePath: string): string {
try {
return readFileSync(filePath).toString().replace(_BOM, ""); // TODO: is replacing BOM's necessary?
} catch {
Expand Down
2 changes: 1 addition & 1 deletion deno_dist/mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,6 @@ export { templates } from "./containers.ts";
export {
config,
config as defaultConfig,
getConfig,
configure,
getConfig,
} from "./config.ts";
8 changes: 4 additions & 4 deletions deno_dist/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { copyProps } from "./utils.ts";
*/
class Cacher<T> {
constructor(private cache: Record<string, T>) {}
define(key: string, val: T) {
define(key: string, val: T): void {
this.cache[key] = val;
}
get(key: string): T {
Expand All @@ -17,13 +17,13 @@ class Cacher<T> {
// TODO: create plugin to allow referencing helpers, filters with dot notation
return this.cache[key];
}
remove(key: string) {
remove(key: string): void {
delete this.cache[key];
}
reset() {
reset(): void {
this.cache = {};
}
load(cacheObj: Record<string, T>) {
load(cacheObj: Record<string, T>): void {
copyProps(this.cache, cacheObj);
}
}
Expand Down
6 changes: 3 additions & 3 deletions deno_dist/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ interface EscapeMap {

/* END TYPES */

export function hasOwnProp(obj: object, prop: string) {
export function hasOwnProp(obj: object, prop: string): boolean {
return Object.prototype.hasOwnProperty.call(obj, prop);
}

export function copyProps<T>(toObj: T, fromObj: T) {
export function copyProps<T>(toObj: T, fromObj: T): T {
for (var key in fromObj) {
if (hasOwnProp((fromObj as unknown) as object, key)) {
toObj[key] = fromObj[key];
Expand Down Expand Up @@ -113,7 +113,7 @@ function replaceChar(s: string): string {
* @returns XML-escaped string
*/

function XMLEscape(str: any) {
function XMLEscape(str: any): string {
// eslint-disable-line @typescript-eslint/no-explicit-any
// To deal with XSS. Based on Escape implementations of Mustache.JS and Marko, then customized.
var newStr = String(str);
Expand Down

0 comments on commit cc47951

Please sign in to comment.