Socket
Socket
Sign inDemoInstall

@types/common-tags

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@types/common-tags - npm Package Compare versions

Comparing version 1.4.0 to 1.8.0

229

common-tags/index.d.ts

@@ -1,67 +0,220 @@

// Type definitions for common-tags v1.4.0
// Type definitions for common-tags 1.8
// Project: https://github.com/declandewet/common-tags
// Definitions by: Viktor Zozuliak <https://github.com/zuzusik>
// Paul Wang <https://github.com/tzupengwang>
// BendingBender <https://github.com/BendingBender>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
declare module 'common-tags' {
type TemplateTag = (literals: TemplateStringsArray, ...placeholders: any[]) => string;
export as namespace commonTags;
type TemplateTransformer = {
onSubstitution?: (substitution: string, resultSoFar: string) => string;
onEndResult?: (endResult : string) => string;
}
export type JSTag = (literals: TemplateStringsArray, ...placeholders: any[]) => string;
/* Built-in Tags */
export var commaLists: TemplateTag;
export interface TemplateTag {
(str: string): string;
(tag: JSTag): TemplateTag;
(literals: TemplateStringsArray, ...placeholders: any[]): string;
}
export var commaListsAnd: TemplateTag;
/**
* You'll often find that you might want to include an array in a template.
* Typically, doing something like `${array.join(', ')}` would work - but what if you're printing a list of items
* in an HTML template and want to maintain the indentation? You'd have to count the spaces manually and include
* them in the `.join()` call - which is a bit ugly for my taste.
* This tag properly indents arrays, as well as newline characters in string substitutions,
* by converting them to an array split by newline and re-using the same array inclusion logic.
*/
export const html: TemplateTag;
export var commaListsOr: TemplateTag;
/**
* alias for `html`
*/
export const codeBlock: TemplateTag;
export var html: TemplateTag;
/**
* alias for `html`
*/
export const source: TemplateTag;
export var codeBlock: TemplateTag;
/**
* A tag very similar to `html` but it does safe HTML escaping for strings coming from substitutions.
* When combined with regular `html` tag, you can do basic HTML templating that is safe from
* XSS (Cross-Site Scripting) attacks.
*/
export const safeHtml: TemplateTag;
export var source: TemplateTag;
/**
* Allows you to keep your single-line strings under 80 characters without resorting to crazy string concatenation.
*/
export const oneLine: TemplateTag;
export var safeHtml: TemplateTag;
/**
* Allows you to keep your single-line strings under 80 characters while trimming the new lines.
*/
export const oneLineTrim: TemplateTag;
export var oneLine: TemplateTag;
/**
* If you want to strip the initial indentation from the beginning of each line in a multiline string.
* Important note: this tag will not indent multiline strings coming from the substitutions.
* If you want that behavior, use the `html` tag (aliases: `source`, `codeBlock`).
*/
export const stripIndent: TemplateTag;
export var oneLineTrim: TemplateTag;
/**
* If you want to strip *all* of the indentation from the beginning of each line in a multiline string.
*/
export const stripIndents: TemplateTag;
export var oneLineCommaLists: TemplateTag;
/**
* Allows you to inline an array substitution as a list.
*/
export const inlineLists: TemplateTag;
export var oneLineCommaListsOr: TemplateTag;
/**
* Allows you to inline an array substitution as a list, rendered out on a single line.
*/
export const oneLineInlineLists: TemplateTag;
export var oneLineCommaListsAnd: TemplateTag;
/**
* Allows you to inline an array substitution as a comma-separated list.
*/
export const commaLists: TemplateTag;
export var inlineLists: TemplateTag;
/**
* Allows you to inline an array substitution as a comma-separated list, the last of which is preceded by the word "or".
*/
export const commaListsOr: TemplateTag;
export var oneLineInlineLists: TemplateTag;
/**
* Allows you to inline an array substitution as a comma-separated list, the last of which is preceded by the word "and".
*/
export const commaListsAnd: TemplateTag;
export var stripIndent: TemplateTag;
/**
* Allows you to inline an array substitution as a comma-separated list, and is rendered out on to a single line.
*/
export const oneLineCommaLists: TemplateTag;
export var stripIndents: TemplateTag;
/**
* Allows you to inline an array substitution as a comma-separated list, the last of which is preceded by the word "or", and is rendered out on to a single line.
*/
export const oneLineCommaListsOr: TemplateTag;
/* New Tag Constructor */
export var TemplateTag: {
new(): TemplateTag;
new(...transformers: TemplateTransformer[]): TemplateTag;
new(transformers: TemplateTransformer[]): TemplateTag;
};
/**
* Allows you to inline an array substitution as a comma-separated list, the last of which is preceded by the word "and", and is rendered out on to a single line.
*/
export const oneLineCommaListsAnd: TemplateTag;
/* Built-in Transformers */
export var trimResultTransformer: (side?: 'left'|'right') => TemplateTransformer;
/**
* A no-op tag that might come in useful in some scenarios, e.g. mocking.
*/
export const id: TemplateTag;
export var stripIndentTransformer: (type?: 'initial'|'all') => TemplateTransformer;
export interface TemplateTransformer<TCtx = { [key: string]: any }> {
/**
* Called before everything else.
* The result of this hook will be passed to other hooks as `context`.
* If omitted, `context` will be an empty object.
*/
getInitialContext?: () => TCtx;
/**
* Called when the tag encounters a string.
* (a string is whatever's not inside "${}" in your template literal)
* `str` is the value of the current string
*/
onString?: (str: string, context: TCtx) => string;
/**
* Called when the tag encounters a substitution.
* (a substitution is whatever's inside "${}" in your template literal)
* `substitution` is the value of the current substitution
* `resultSoFar` is the end result up to the point of this substitution
*/
onSubstitution?: (substitution: string, resultSoFar: string, context: TCtx) => string;
/**
* Called when all substitutions have been parsed
* `endResult` is the final value.
*/
onEndResult?: (endResult: string, context: TCtx) => string;
}
export var replaceResultTransformer: (replaceWhat: string|RegExp, replaceWith: string) => TemplateTransformer;
export type PluginFunction = (oldValue: string, newValue: string) => TemplateTransformer<any>;
export var replaceSubstitutionTransformer: (replaceWhat: string|RegExp, replaceWith: string) => TemplateTransformer;
/**
* New Tag factory
*/
export function createTag(transformers?: Array<TemplateTransformer<any>>): TemplateTag;
export function createTag(...transformers: Array<TemplateTransformer<any>>): TemplateTag;
export function createTag(...pluginFunctions: PluginFunction[]): TemplateTag;
export var inlineArrayTransformer: (opts?: {separator?: string, conjunction?: string}) => TemplateTransformer;
export const TemplateTag: {
/**
* New Tag Constructor
* @deprecated
*/
new (transformers?: Array<TemplateTransformer<any>>): TemplateTag;
new (...transformers: Array<TemplateTransformer<any>>): TemplateTag;
new (...pluginFunctions: PluginFunction[]): TemplateTag;
};
export var splitStringTransformer: (splitBy: string) => TemplateTransformer;
}
/**
* TemplateTag transformer that trims whitespace on the end result of a tagged template
* @param [side=''] The side of the string to trim. Can be 'start' or 'end' (alternatively 'left' or 'right')
* @return a TemplateTag transformer
*/
export function trimResultTransformer(
side?: 'start' | 'end' | 'left' | 'right' | ''
): TemplateTransformer;
/**
* strips indentation from a template literal
* @param [type='initial'] whether to remove all indentation or just leading indentation. can be 'all' or 'initial'
* @return a TemplateTag transformer
*/
export function stripIndentTransformer(type?: 'initial' | 'all'): TemplateTransformer;
/**
* Replaces a value or pattern in the end result with a new value.
* @param replaceWhat the value or pattern that should be replaced
* @param replaceWith the replacement value
* @return a TemplateTag transformer
*/
export function replaceResultTransformer(
replaceWhat: string | RegExp,
replaceWith: string | ((substring: string, ...args: any[]) => string)
): TemplateTransformer;
/**
* Replaces the result of all substitutions (results of calling ${ ... }) with a new value.
* Same as for `replaceResultTransformer`, replaceWhat can be a string or regular expression and replaceWith is the new value.
*/
export function replaceSubstitutionTransformer(
replaceWhat: string | RegExp,
replaceWith: string | ((substring: string, ...args: any[]) => string)
): TemplateTransformer;
/**
* Replaces the result of all strings (what's not in ${ ... }) with a new value.
* Same as for `replaceResultTransformer`, replaceWhat can be a string or regular expression and replaceWith is the new value.
*/
export function replaceStringTransformer(
replaceWhat: string | RegExp,
replaceWith: string | ((substring: string, ...args: any[]) => string)
): TemplateTransformer;
/**
* Converts an array substitution to a string containing a list
* @param [opts.separator=''] what to separate each item with (always followed by a space)
* @param [opts.conjunction=''] replace the last separator with this value
* @param [opts.serial=false] should the separator be included before the conjunction? As in the case of serial/oxford commas
* @return a TemplateTag transformer
*/
export function inlineArrayTransformer(opts?: {
separator?: string;
conjunction?: string;
serial?: boolean;
}): TemplateTransformer;
/**
* Splits a string substitution into an array by the provided splitBy substring, only if the string contains the splitBy substring.
*/
export function splitStringTransformer(splitBy: string): TemplateTransformer;

14

common-tags/package.json
{
"name": "@types/common-tags",
"version": "1.4.0",
"version": "1.8.0",
"description": "TypeScript definitions for common-tags",

@@ -16,13 +16,19 @@ "license": "MIT",

"githubUsername": "tzupengwang"
},
{
"name": "BendingBender",
"url": "https://github.com/BendingBender",
"githubUsername": "BendingBender"
}
],
"main": "",
"types": "index",
"repository": {
"type": "git",
"url": "https://www.github.com/DefinitelyTyped/DefinitelyTyped.git"
"url": "https://github.com/DefinitelyTyped/DefinitelyTyped.git"
},
"scripts": {},
"dependencies": {},
"typesPublisherContentHash": "41d942e7932d76cc247f2b451ae19e49c9e6db8e129e0b32affb486fb241f801",
"typeScriptVersion": "2.0"
"typesPublisherContentHash": "0a69c3453d0a952fe8cd008ebf730e80f11820a9e493bd3271d40a2d973f39a3",
"typeScriptVersion": "2.3"
}

@@ -8,10 +8,10 @@ # Installation

# Details
Files were exported from https://www.github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/common-tags
Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/common-tags
Additional Details
* Last updated: Mon, 18 Sep 2017 14:08:00 GMT
* Last updated: Fri, 07 Dec 2018 18:53:10 GMT
* Dependencies: none
* Global values: none
* Global values: commonTags
# Credits
These definitions were written by Viktor Zozuliak <https://github.com/zuzusik>, Paul Wang <https://github.com/tzupengwang>.
These definitions were written by Viktor Zozuliak <https://github.com/zuzusik>, Paul Wang <https://github.com/tzupengwang>, BendingBender <https://github.com/BendingBender>.
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc