Skip to content

Commit b50838e

Browse files
author
Tim Hambourger
committed
feat: opts -> options (piotr-oles#34)
1 parent 992eb72 commit b50838e

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

packages/emitter/src/index.ts

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,9 @@ function selectQuote(
7070
}
7171
}
7272

73-
function escapeValue(value: string, opts: EmitOptions) {
73+
function escapeValue(value: string, options: EmitOptions) {
7474
if (value === "" || ReservedChars.some((reservedChar) => value.includes(reservedChar))) {
75-
const quote = selectQuote(value, opts);
75+
const quote = selectQuote(value, options);
7676
return `${quote}${escapeQuotes(value, quote)}${quote}`;
7777
}
7878

@@ -83,19 +83,19 @@ function emitSelector(node: SelectorNode) {
8383
return node.selector;
8484
}
8585

86-
function emitValue(node: ValueNode, opts: EmitOptions) {
86+
function emitValue(node: ValueNode, options: EmitOptions) {
8787
return Array.isArray(node.value)
88-
? `(${node.value.map((value) => escapeValue(value, opts)).join(",")})`
89-
: escapeValue(node.value, opts);
88+
? `(${node.value.map((value) => escapeValue(value, options)).join(",")})`
89+
: escapeValue(node.value, options);
9090
}
9191

92-
function emitComparison(node: ComparisonNode, opts: EmitOptions) {
93-
return `${emitSelector(node.left)}${node.operator}${emitValue(node.right, opts)}`;
92+
function emitComparison(node: ComparisonNode, options: EmitOptions) {
93+
return `${emitSelector(node.left)}${node.operator}${emitValue(node.right, options)}`;
9494
}
9595

96-
function emitLogic(node: LogicNode, opts: EmitOptions) {
97-
let left = emitWithoutOptsValidation(node.left, opts);
98-
let right = emitWithoutOptsValidation(node.right, opts);
96+
function emitLogic(node: LogicNode, options: EmitOptions) {
97+
let left = emitWithoutOptionsValidation(node.left, options);
98+
let right = emitWithoutOptionsValidation(node.right, options);
9999

100100
// handle operator precedence - as it's only the case for AND operator, we don't need a generic logic for that
101101
if (isLogicOperator(node.operator, AND)) {
@@ -113,23 +113,23 @@ function emitLogic(node: LogicNode, opts: EmitOptions) {
113113
return `${left}${operator}${right}`;
114114
}
115115

116-
function emitWithoutOptsValidation(expression: ExpressionNode, opts: EmitOptions): string {
116+
function emitWithoutOptionsValidation(expression: ExpressionNode, options: EmitOptions): string {
117117
if (isComparisonNode(expression)) {
118-
return emitComparison(expression, opts);
118+
return emitComparison(expression, options);
119119
} else if (isLogicNode(expression)) {
120-
return emitLogic(expression, opts);
120+
return emitLogic(expression, options);
121121
}
122122

123123
throw new TypeError(`The "expression" has to be a valid "ExpressionNode", ${String(expression)} passed.`);
124124
}
125125

126-
function emit(expression: ExpressionNode, opts: EmitOptions = {}) {
127-
if (opts.preferredQuote !== undefined && opts.preferredQuote !== '"' && opts.preferredQuote !== "'") {
126+
function emit(expression: ExpressionNode, options: EmitOptions = {}) {
127+
if (options.preferredQuote !== undefined && options.preferredQuote !== '"' && options.preferredQuote !== "'") {
128128
throw new TypeError(
129-
`Invalid "preferredQuote" option: ${opts.preferredQuote}. Must be either " (the ASCII double quote character) or ' (the ASCII single quote character).`
129+
`Invalid "preferredQuote" option: ${options.preferredQuote}. Must be either " (the ASCII double quote character) or ' (the ASCII single quote character).`
130130
);
131131
}
132-
return emitWithoutOptsValidation(expression, opts);
132+
return emitWithoutOptionsValidation(expression, options);
133133
}
134134

135135
export { emit, EmitOptions, Quote };

0 commit comments

Comments
 (0)