repo
stringlengths
7
64
file_url
stringlengths
81
338
file_path
stringlengths
5
257
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 15:25:31
2026-01-05 01:50:38
truncated
bool
2 classes
hexojs/hexo
https://github.com/hexojs/hexo/blob/1fd997c3ad772ab7ed85b71b886d55248d92bb68/lib/plugins/helper/is.ts
lib/plugins/helper/is.ts
import type { LocalsType } from '../../types'; function isCurrentHelper(this: LocalsType, path = '/', strict: boolean) { const currentPath = this.path.replace(/^[^/].*/, '/$&'); if (strict) { if (path.endsWith('/')) path += 'index.html'; path = path.replace(/^[^/].*/, '/$&'); return currentPath === p...
typescript
MIT
1fd997c3ad772ab7ed85b71b886d55248d92bb68
2026-01-04T15:50:29.521527Z
false
hexojs/hexo
https://github.com/hexojs/hexo/blob/1fd997c3ad772ab7ed85b71b886d55248d92bb68/lib/plugins/helper/debug.ts
lib/plugins/helper/debug.ts
import { inspect } from 'util'; // this format object as string, resolves circular reference function inspectObject(object: any, options?: any) { return inspect(object, options); } // wrapper to log to console function log(...args: any[]) { return Reflect.apply(console.log, null, args); } export {inspectObject};...
typescript
MIT
1fd997c3ad772ab7ed85b71b886d55248d92bb68
2026-01-04T15:50:29.521527Z
false
hexojs/hexo
https://github.com/hexojs/hexo/blob/1fd997c3ad772ab7ed85b71b886d55248d92bb68/lib/plugins/helper/tagcloud.ts
lib/plugins/helper/tagcloud.ts
import { Color, url_for } from 'hexo-util'; import moize from 'moize'; import type { LocalsType, TagSchema } from '../../types'; import type Query from 'warehouse/dist/query'; interface Options { min_font?: number; max_font?: number; orderby?: string; order?: number; unit?: string; color?: boolean; class...
typescript
MIT
1fd997c3ad772ab7ed85b71b886d55248d92bb68
2026-01-04T15:50:29.521527Z
false
hexojs/hexo
https://github.com/hexojs/hexo/blob/1fd997c3ad772ab7ed85b71b886d55248d92bb68/lib/plugins/helper/list_tags.ts
lib/plugins/helper/list_tags.ts
import { url_for, escapeHTML } from 'hexo-util'; import moize from 'moize'; import type { LocalsType, TagSchema } from '../../types'; import type Query from 'warehouse/dist/query'; interface Options { style?: string | false; class?: any; amount?: number; orderby?: string; order?: number; transform?: (name:...
typescript
MIT
1fd997c3ad772ab7ed85b71b886d55248d92bb68
2026-01-04T15:50:29.521527Z
false
hexojs/hexo
https://github.com/hexojs/hexo/blob/1fd997c3ad772ab7ed85b71b886d55248d92bb68/lib/plugins/helper/favicon_tag.ts
lib/plugins/helper/favicon_tag.ts
import { url_for } from 'hexo-util'; import type { LocalsType } from '../../types'; function faviconTagHelper(this: LocalsType, path: string) { return `<link rel="shortcut icon" href="${url_for.call(this, path)}">`; } export = faviconTagHelper;
typescript
MIT
1fd997c3ad772ab7ed85b71b886d55248d92bb68
2026-01-04T15:50:29.521527Z
false
hexojs/hexo
https://github.com/hexojs/hexo/blob/1fd997c3ad772ab7ed85b71b886d55248d92bb68/lib/plugins/helper/gravatar.ts
lib/plugins/helper/gravatar.ts
import { gravatar } from 'hexo-util'; export = gravatar;
typescript
MIT
1fd997c3ad772ab7ed85b71b886d55248d92bb68
2026-01-04T15:50:29.521527Z
false
hexojs/hexo
https://github.com/hexojs/hexo/blob/1fd997c3ad772ab7ed85b71b886d55248d92bb68/lib/plugins/helper/partial.ts
lib/plugins/helper/partial.ts
import { dirname, join } from 'path'; import type Hexo from '../../hexo'; import type { LocalsType } from '../../types'; interface Options { cache?: boolean | string; only?: boolean; } export = (ctx: Hexo) => function partial(this: LocalsType, name: string, locals?: any, options: Options = {}) { if (typeof name...
typescript
MIT
1fd997c3ad772ab7ed85b71b886d55248d92bb68
2026-01-04T15:50:29.521527Z
false
hexojs/hexo
https://github.com/hexojs/hexo/blob/1fd997c3ad772ab7ed85b71b886d55248d92bb68/lib/plugins/helper/fragment_cache.ts
lib/plugins/helper/fragment_cache.ts
import { Cache } from 'hexo-util'; import type Hexo from '../../hexo'; export = (ctx: Hexo) => { const cache = new Cache(); // reset cache for watch mode ctx.on('generateBefore', () => { cache.flush(); }); return function fragmentCache(id: string, fn: () => any) { if (this.cache) return cache.apply(id, f...
typescript
MIT
1fd997c3ad772ab7ed85b71b886d55248d92bb68
2026-01-04T15:50:29.521527Z
false
hexojs/hexo
https://github.com/hexojs/hexo/blob/1fd997c3ad772ab7ed85b71b886d55248d92bb68/lib/plugins/helper/paginator.ts
lib/plugins/helper/paginator.ts
import { htmlTag, url_for } from 'hexo-util'; import type { LocalsType } from '../../types'; interface Options { base?: string; current?: number; format?: string; total?: number; end_size?: number; mid_size?: number; space?: string; next_text?: string; prev_text?: string; prev_next?: boolean; esc...
typescript
MIT
1fd997c3ad772ab7ed85b71b886d55248d92bb68
2026-01-04T15:50:29.521527Z
false
hexojs/hexo
https://github.com/hexojs/hexo/blob/1fd997c3ad772ab7ed85b71b886d55248d92bb68/lib/plugins/helper/css.ts
lib/plugins/helper/css.ts
import { htmlTag, url_for } from 'hexo-util'; import moize from 'moize'; import type { LocalsType } from '../../types'; let relative_link = true; function cssHelper(this: LocalsType, ...args: any[]) { let result = '\n'; relative_link = this.config.relative_link; args.flat(Infinity).forEach(item => { if (ty...
typescript
MIT
1fd997c3ad772ab7ed85b71b886d55248d92bb68
2026-01-04T15:50:29.521527Z
false
hexojs/hexo
https://github.com/hexojs/hexo/blob/1fd997c3ad772ab7ed85b71b886d55248d92bb68/lib/plugins/helper/list_categories.ts
lib/plugins/helper/list_categories.ts
import { url_for } from 'hexo-util'; import type { CategorySchema, LocalsType } from '../../types'; import type Query from 'warehouse/dist/query'; import type Document from 'warehouse/dist/document'; interface Options { style?: string | false; class?: string; depth?: number | string; orderby?: string; order?...
typescript
MIT
1fd997c3ad772ab7ed85b71b886d55248d92bb68
2026-01-04T15:50:29.521527Z
false
hexojs/hexo
https://github.com/hexojs/hexo/blob/1fd997c3ad772ab7ed85b71b886d55248d92bb68/lib/plugins/helper/url_for.ts
lib/plugins/helper/url_for.ts
import { url_for } from 'hexo-util'; import type { LocalsType } from '../../types'; interface Options { relative?: boolean } export = function(this: LocalsType, path: string, options: Options = {}) { return url_for.call(this, path, options); }
typescript
MIT
1fd997c3ad772ab7ed85b71b886d55248d92bb68
2026-01-04T15:50:29.521527Z
false
hexojs/hexo
https://github.com/hexojs/hexo/blob/1fd997c3ad772ab7ed85b71b886d55248d92bb68/lib/plugins/helper/js.ts
lib/plugins/helper/js.ts
import { htmlTag, url_for } from 'hexo-util'; import moize from 'moize'; import type { LocalsType } from '../../types'; let relative_link = true; function jsHelper(this: LocalsType, ...args: any[]) { let result = '\n'; relative_link = this.config.relative_link; args.flat(Infinity).forEach(item => { if (typ...
typescript
MIT
1fd997c3ad772ab7ed85b71b886d55248d92bb68
2026-01-04T15:50:29.521527Z
false
hexojs/hexo
https://github.com/hexojs/hexo/blob/1fd997c3ad772ab7ed85b71b886d55248d92bb68/lib/plugins/helper/markdown.ts
lib/plugins/helper/markdown.ts
import type { LocalsType } from '../../types'; function markdownHelper(this: LocalsType, text: string, options?: any) { return this.render(text, 'markdown', options); } export = markdownHelper;
typescript
MIT
1fd997c3ad772ab7ed85b71b886d55248d92bb68
2026-01-04T15:50:29.521527Z
false
hexojs/hexo
https://github.com/hexojs/hexo/blob/1fd997c3ad772ab7ed85b71b886d55248d92bb68/lib/plugins/helper/feed_tag.ts
lib/plugins/helper/feed_tag.ts
import { url_for } from 'hexo-util'; import moize from 'moize'; import type { LocalsType } from '../../types'; const feedFn = (str = '') => { if (str) return str.replace(/2$/, ''); return str; }; interface Options { title?: string; type?: string | null; } function makeFeedTag(this: LocalsType, path?: string,...
typescript
MIT
1fd997c3ad772ab7ed85b71b886d55248d92bb68
2026-01-04T15:50:29.521527Z
false
hexojs/hexo
https://github.com/hexojs/hexo/blob/1fd997c3ad772ab7ed85b71b886d55248d92bb68/lib/plugins/helper/format.ts
lib/plugins/helper/format.ts
import { stripHTML, wordWrap, truncate, escapeHTML } from 'hexo-util'; import titlecase from 'titlecase'; export {stripHTML as strip_html}; export {stripHTML}; export function trim(str: string) { return str.trim(); } export {titlecase}; export {wordWrap as word_wrap}; export {wordWrap}; export {truncate}; export {e...
typescript
MIT
1fd997c3ad772ab7ed85b71b886d55248d92bb68
2026-01-04T15:50:29.521527Z
false
hexojs/hexo
https://github.com/hexojs/hexo/blob/1fd997c3ad772ab7ed85b71b886d55248d92bb68/lib/plugins/helper/list_archives.ts
lib/plugins/helper/list_archives.ts
import type Query from 'warehouse/dist/query'; import type { LocalsType, PostSchema } from '../../types'; import { toMomentLocale } from './date'; import { url_for, Cache } from 'hexo-util'; interface Options { format?: string; type?: string; style?: string | false; transform?: (name: string) => string; sepa...
typescript
MIT
1fd997c3ad772ab7ed85b71b886d55248d92bb68
2026-01-04T15:50:29.521527Z
false
hexojs/hexo
https://github.com/hexojs/hexo/blob/1fd997c3ad772ab7ed85b71b886d55248d92bb68/lib/plugins/helper/meta_generator.ts
lib/plugins/helper/meta_generator.ts
import type { LocalsType } from '../../types'; function metaGeneratorHelper(this: LocalsType) { return `<meta name="generator" content="Hexo ${this.env.version}">`; } export = metaGeneratorHelper;
typescript
MIT
1fd997c3ad772ab7ed85b71b886d55248d92bb68
2026-01-04T15:50:29.521527Z
false
hexojs/hexo
https://github.com/hexojs/hexo/blob/1fd997c3ad772ab7ed85b71b886d55248d92bb68/lib/plugins/helper/full_url_for.ts
lib/plugins/helper/full_url_for.ts
import { full_url_for } from 'hexo-util'; import type { LocalsType } from '../../types'; export = function(this: LocalsType, path?: string) { return full_url_for.call(this, path); }
typescript
MIT
1fd997c3ad772ab7ed85b71b886d55248d92bb68
2026-01-04T15:50:29.521527Z
false
hexojs/hexo
https://github.com/hexojs/hexo/blob/1fd997c3ad772ab7ed85b71b886d55248d92bb68/lib/plugins/helper/mail_to.ts
lib/plugins/helper/mail_to.ts
import { htmlTag } from 'hexo-util'; import moize from 'moize'; interface Options { href?: string; title?: string; class?: string | string[]; subject?: string; cc?: string | string[]; bcc?: string | string[]; id?: string; body?: string; } interface Attrs { href: string; title: string; class?: st...
typescript
MIT
1fd997c3ad772ab7ed85b71b886d55248d92bb68
2026-01-04T15:50:29.521527Z
false
hexojs/hexo
https://github.com/hexojs/hexo/blob/1fd997c3ad772ab7ed85b71b886d55248d92bb68/lib/plugins/helper/search_form.ts
lib/plugins/helper/search_form.ts
import moize from 'moize'; import type { LocalsType } from '../../types'; interface Options { class?: string; text?: string | null; button?: string | boolean; } function searchFormHelper(this: LocalsType, options: Options = {}) { const { config } = this; const className = options.class || 'search-form'; c...
typescript
MIT
1fd997c3ad772ab7ed85b71b886d55248d92bb68
2026-01-04T15:50:29.521527Z
false
hexojs/hexo
https://github.com/hexojs/hexo/blob/1fd997c3ad772ab7ed85b71b886d55248d92bb68/lib/plugins/helper/link_to.ts
lib/plugins/helper/link_to.ts
import { htmlTag, url_for } from 'hexo-util'; import type { LocalsType } from '../../types'; interface Options { id?: string; href?: string; title?: string; external?: boolean | null; class?: string | string[]; target?: string; rel?: string; } interface Attrs { href: string; title: string; externa...
typescript
MIT
1fd997c3ad772ab7ed85b71b886d55248d92bb68
2026-01-04T15:50:29.521527Z
false
hexojs/hexo
https://github.com/hexojs/hexo/blob/1fd997c3ad772ab7ed85b71b886d55248d92bb68/lib/plugins/helper/open_graph.ts
lib/plugins/helper/open_graph.ts
import { isMoment, isDate, Moment } from 'moment'; import { encodeURL, prettyUrls, stripHTML, escapeHTML } from 'hexo-util'; import moize from 'moize'; import type { LocalsType } from '../../types'; const localeMap = { 'en': 'en_US', 'de': 'de_DE', 'es': 'es_ES', 'fr': 'fr_FR', 'hu': 'hu_HU', 'id': 'id_ID'...
typescript
MIT
1fd997c3ad772ab7ed85b71b886d55248d92bb68
2026-01-04T15:50:29.521527Z
false
hexojs/hexo
https://github.com/hexojs/hexo/blob/1fd997c3ad772ab7ed85b71b886d55248d92bb68/lib/plugins/helper/index.ts
lib/plugins/helper/index.ts
import type Hexo from '../../hexo'; export = (ctx: Hexo) => { const { helper } = ctx.extend; const date = require('./date'); helper.register('date', date.date); helper.register('date_xml', date.date_xml); helper.register('time', date.time); helper.register('full_date', date.full_date); helper.register(...
typescript
MIT
1fd997c3ad772ab7ed85b71b886d55248d92bb68
2026-01-04T15:50:29.521527Z
false
hexojs/hexo
https://github.com/hexojs/hexo/blob/1fd997c3ad772ab7ed85b71b886d55248d92bb68/lib/plugins/helper/list_posts.ts
lib/plugins/helper/list_posts.ts
import { url_for } from 'hexo-util'; import type { LocalsType, PostSchema } from '../../types'; import type Query from 'warehouse/dist/query'; interface Options { style?: string | false; class?: string; amount?: number; orderby?: string; order?: number; transform?: (name: string) => string; separator?: s...
typescript
MIT
1fd997c3ad772ab7ed85b71b886d55248d92bb68
2026-01-04T15:50:29.521527Z
false
hexojs/hexo
https://github.com/hexojs/hexo/blob/1fd997c3ad772ab7ed85b71b886d55248d92bb68/lib/plugins/helper/date.ts
lib/plugins/helper/date.ts
import moment from 'moment-timezone'; const { isMoment } = moment; import moize from 'moize'; import type { LocalsType } from '../../types'; const isDate = (value: moment.MomentInput | moment.Moment): boolean => typeof value === 'object' && value instanceof Date && !isNaN(value.getTime()); function getMoment(date: ...
typescript
MIT
1fd997c3ad772ab7ed85b71b886d55248d92bb68
2026-01-04T15:50:29.521527Z
false
hexojs/hexo
https://github.com/hexojs/hexo/blob/1fd997c3ad772ab7ed85b71b886d55248d92bb68/lib/plugins/tag/blockquote.ts
lib/plugins/tag/blockquote.ts
// Based on: https://raw.github.com/imathis/octopress/master/plugins/blockquote.rb import titlecase from 'titlecase'; import type Hexo from '../../hexo'; const rFullCiteWithTitle = /(\S.*)\s+(https?:\/\/\S+)\s+(.+)/i; const rFullCite = /(\S.*)\s+(https?:\/\/\S+)/i; const rAuthorTitle = /([^,]+),\s*([^,]+)/; /** * @...
typescript
MIT
1fd997c3ad772ab7ed85b71b886d55248d92bb68
2026-01-04T15:50:29.521527Z
false
hexojs/hexo
https://github.com/hexojs/hexo/blob/1fd997c3ad772ab7ed85b71b886d55248d92bb68/lib/plugins/tag/link.ts
lib/plugins/tag/link.ts
import { htmlTag } from 'hexo-util'; const rUrl = /((([A-Za-z]{3,9}:(?:\/\/)?)(?:[-;:&=+$,\w]+@)?[A-Za-z0-9.-]+|(?:www.|[-;:&=+$,\w]+@)[A-Za-z0-9.-]+)((?:\/[+~%/.\w-_]*)?\??(?:[-+=&;%@.\w_]*)#?(?:[.!/\\w]*))?)/; /** * Link tag * * Syntax: * {% link text url [external] [title] %} */ function linkTag(args: string[])...
typescript
MIT
1fd997c3ad772ab7ed85b71b886d55248d92bb68
2026-01-04T15:50:29.521527Z
false
hexojs/hexo
https://github.com/hexojs/hexo/blob/1fd997c3ad772ab7ed85b71b886d55248d92bb68/lib/plugins/tag/code.ts
lib/plugins/tag/code.ts
// Based on: https://raw.github.com/imathis/octopress/master/plugins/code_block.rb import { escapeHTML, htmlTag } from 'hexo-util'; import type Hexo from '../../hexo'; import type { HighlightOptions } from '../../extend/syntax_highlight'; const rCaptionUrlTitle = /(\S[\S\s]*)\s+(https?:\/\/\S+)\s+(.+)/i; const rCapti...
typescript
MIT
1fd997c3ad772ab7ed85b71b886d55248d92bb68
2026-01-04T15:50:29.521527Z
false
hexojs/hexo
https://github.com/hexojs/hexo/blob/1fd997c3ad772ab7ed85b71b886d55248d92bb68/lib/plugins/tag/asset_link.ts
lib/plugins/tag/asset_link.ts
import { url_for, escapeHTML } from 'hexo-util'; import type Hexo from '../../hexo'; /** * Asset link tag * * Syntax: * {% asset_link slug [title] [escape] %} */ export = (ctx: Hexo) => { const PostAsset = ctx.model('PostAsset'); return function assetLinkTag(args: string[]) { const slug = args.shift();...
typescript
MIT
1fd997c3ad772ab7ed85b71b886d55248d92bb68
2026-01-04T15:50:29.521527Z
false
hexojs/hexo
https://github.com/hexojs/hexo/blob/1fd997c3ad772ab7ed85b71b886d55248d92bb68/lib/plugins/tag/url_for.ts
lib/plugins/tag/url_for.ts
import { url_for, htmlTag } from 'hexo-util'; import type Hexo from '../../hexo'; /** * Url for tag * * Syntax: * {% url_for text path [relative] %} */ export = (ctx: Hexo) => { return function urlForTag([text, path, relative]) { const url = url_for.call(ctx, path, relative ? { relative: relative !== 'fal...
typescript
MIT
1fd997c3ad772ab7ed85b71b886d55248d92bb68
2026-01-04T15:50:29.521527Z
false
hexojs/hexo
https://github.com/hexojs/hexo/blob/1fd997c3ad772ab7ed85b71b886d55248d92bb68/lib/plugins/tag/img.ts
lib/plugins/tag/img.ts
import { htmlTag, url_for } from 'hexo-util'; import type Hexo from '../../hexo'; const rUrl = /((([A-Za-z]{3,9}:(?:\/\/)?)(?:[-;:&=+$,\w]+@)?[A-Za-z0-9.-]+|(?:www.|[-;:&=+$,\w]+@)[A-Za-z0-9.-]+)((?:\/[+~%/.\w-_]*)?\??(?:[-+=&;%@.\w_]*)#?(?:[.!/\\w]*))?)/; const rMetaDoubleQuote = /"?([^"]+)?"?/; const rMetaSingleQuot...
typescript
MIT
1fd997c3ad772ab7ed85b71b886d55248d92bb68
2026-01-04T15:50:29.521527Z
false
hexojs/hexo
https://github.com/hexojs/hexo/blob/1fd997c3ad772ab7ed85b71b886d55248d92bb68/lib/plugins/tag/iframe.ts
lib/plugins/tag/iframe.ts
import { htmlTag } from 'hexo-util'; /** * Iframe tag * * Syntax: * {% iframe url [width] [height] %} */ function iframeTag(args: string[]) { const src = args[0]; const width = args[1] && args[1] !== 'default' ? args[1] : '100%'; const height = args[2] && args[2] !== 'default' ? args[2] : '300'; const attr...
typescript
MIT
1fd997c3ad772ab7ed85b71b886d55248d92bb68
2026-01-04T15:50:29.521527Z
false
hexojs/hexo
https://github.com/hexojs/hexo/blob/1fd997c3ad772ab7ed85b71b886d55248d92bb68/lib/plugins/tag/asset_img.ts
lib/plugins/tag/asset_img.ts
import img from './img'; import { encodeURL } from 'hexo-util'; import type Hexo from '../../hexo'; /** * Asset image tag * * Syntax: * {% asset_img [class names] slug [width] [height] [title text [alt text]]%} */ export = (ctx: Hexo) => { const PostAsset = ctx.model('PostAsset'); return function assetImgT...
typescript
MIT
1fd997c3ad772ab7ed85b71b886d55248d92bb68
2026-01-04T15:50:29.521527Z
false
hexojs/hexo
https://github.com/hexojs/hexo/blob/1fd997c3ad772ab7ed85b71b886d55248d92bb68/lib/plugins/tag/full_url_for.ts
lib/plugins/tag/full_url_for.ts
import { full_url_for, htmlTag } from 'hexo-util'; import type Hexo from '../../hexo'; /** * Full url for tag * * Syntax: * {% full_url_for text path %} */ export = (ctx: Hexo) => { return function fullUrlForTag([text, path]) { const url = full_url_for.call(ctx, path); const attrs = { href: url ...
typescript
MIT
1fd997c3ad772ab7ed85b71b886d55248d92bb68
2026-01-04T15:50:29.521527Z
false
hexojs/hexo
https://github.com/hexojs/hexo/blob/1fd997c3ad772ab7ed85b71b886d55248d92bb68/lib/plugins/tag/include_code.ts
lib/plugins/tag/include_code.ts
import { basename, extname, join } from 'path'; import { htmlTag, url_for } from 'hexo-util'; import type Hexo from '../../hexo'; const rCaptionTitleFile = /(.*)?(?:\s+|^)(\/*\S+)/; const rLang = /\s*lang:(\w+)/i; const rFrom = /\s*from:(\d+)/i; const rTo = /\s*to:(\d+)/i; /** * Include code tag * * Syntax: * {% in...
typescript
MIT
1fd997c3ad772ab7ed85b71b886d55248d92bb68
2026-01-04T15:50:29.521527Z
false
hexojs/hexo
https://github.com/hexojs/hexo/blob/1fd997c3ad772ab7ed85b71b886d55248d92bb68/lib/plugins/tag/index.ts
lib/plugins/tag/index.ts
import moize from 'moize'; import type Hexo from '../../hexo'; export default (ctx: Hexo) => { const { tag } = ctx.extend; const blockquote = require('./blockquote')(ctx); tag.register('quote', blockquote, true); tag.register('blockquote', blockquote, true); const code = require('./code')(ctx); tag.reg...
typescript
MIT
1fd997c3ad772ab7ed85b71b886d55248d92bb68
2026-01-04T15:50:29.521527Z
false
hexojs/hexo
https://github.com/hexojs/hexo/blob/1fd997c3ad772ab7ed85b71b886d55248d92bb68/lib/plugins/tag/asset_path.ts
lib/plugins/tag/asset_path.ts
import { url_for } from 'hexo-util'; import type Hexo from '../../hexo'; /** * Asset path tag * * Syntax: * {% asset_path slug %} */ export = (ctx: Hexo) => { const PostAsset = ctx.model('PostAsset'); return function assetPathTag(args: string[]) { const slug = args.shift(); if (!slug) return; ...
typescript
MIT
1fd997c3ad772ab7ed85b71b886d55248d92bb68
2026-01-04T15:50:29.521527Z
false
hexojs/hexo
https://github.com/hexojs/hexo/blob/1fd997c3ad772ab7ed85b71b886d55248d92bb68/lib/plugins/tag/post_link.ts
lib/plugins/tag/post_link.ts
import { url_for, escapeHTML } from 'hexo-util'; import { postFindOneFactory } from './'; import type Hexo from '../../hexo'; /** * Post link tag * * Syntax: * {% post_link slug | title [title] [escape] %} */ export = (ctx: Hexo) => { return function postLinkTag(args: string[]) { let slug = args.shift(); ...
typescript
MIT
1fd997c3ad772ab7ed85b71b886d55248d92bb68
2026-01-04T15:50:29.521527Z
false
hexojs/hexo
https://github.com/hexojs/hexo/blob/1fd997c3ad772ab7ed85b71b886d55248d92bb68/lib/plugins/tag/pullquote.ts
lib/plugins/tag/pullquote.ts
import type Hexo from '../../hexo'; /** * Pullquote tag * * Syntax: * {% pullquote [class] %} * Quote string * {% endpullquote %} */ export = (ctx: Hexo) => function pullquoteTag(args: string[], content: string) { args.unshift('pullquote'); const result = ctx.render.renderSync({text: content, engine: 'markd...
typescript
MIT
1fd997c3ad772ab7ed85b71b886d55248d92bb68
2026-01-04T15:50:29.521527Z
false
hexojs/hexo
https://github.com/hexojs/hexo/blob/1fd997c3ad772ab7ed85b71b886d55248d92bb68/lib/plugins/tag/post_path.ts
lib/plugins/tag/post_path.ts
import { url_for } from 'hexo-util'; import { postFindOneFactory } from './'; import type Hexo from '../../hexo'; /** * Post path tag * * Syntax: * {% post_path slug | title %} */ export = (ctx: Hexo) => { return function postPathTag(args: any[]) { const slug = args.shift(); if (!slug) return; co...
typescript
MIT
1fd997c3ad772ab7ed85b71b886d55248d92bb68
2026-01-04T15:50:29.521527Z
false
hexojs/hexo
https://github.com/hexojs/hexo/blob/1fd997c3ad772ab7ed85b71b886d55248d92bb68/lib/plugins/highlight/prism.ts
lib/plugins/highlight/prism.ts
import type { HighlightOptions } from '../../extend/syntax_highlight'; import type Hexo from '../../hexo'; // Lazy require prismjs let prismHighlight: typeof import('hexo-util').prismHighlight; module.exports = function(this: Hexo, code: string, options: HighlightOptions) { const prismjsCfg = this.config.prismjs ||...
typescript
MIT
1fd997c3ad772ab7ed85b71b886d55248d92bb68
2026-01-04T15:50:29.521527Z
false
hexojs/hexo
https://github.com/hexojs/hexo/blob/1fd997c3ad772ab7ed85b71b886d55248d92bb68/lib/plugins/highlight/index.ts
lib/plugins/highlight/index.ts
import type Hexo from '../../hexo'; module.exports = (ctx: Hexo) => { const { highlight } = ctx.extend; highlight.register('highlight.js', require('./highlight')); highlight.register('prismjs', require('./prism')); };
typescript
MIT
1fd997c3ad772ab7ed85b71b886d55248d92bb68
2026-01-04T15:50:29.521527Z
false
hexojs/hexo
https://github.com/hexojs/hexo/blob/1fd997c3ad772ab7ed85b71b886d55248d92bb68/lib/plugins/highlight/highlight.ts
lib/plugins/highlight/highlight.ts
import type { HighlightOptions } from '../../extend/syntax_highlight'; import type Hexo from '../../hexo'; // Lazy require highlight.js let highlight: typeof import('hexo-util').highlight; module.exports = function highlightFilter(this: Hexo, code: string, options: HighlightOptions) { const hljsCfg = this.config.hi...
typescript
MIT
1fd997c3ad772ab7ed85b71b886d55248d92bb68
2026-01-04T15:50:29.521527Z
false
hexojs/hexo
https://github.com/hexojs/hexo/blob/1fd997c3ad772ab7ed85b71b886d55248d92bb68/lib/theme/index.ts
lib/theme/index.ts
import { extname } from 'path'; import Box from '../box'; import View from './view'; import I18n from 'hexo-i18n'; import { config } from './processors/config'; import { i18n } from './processors/i18n'; import { source } from './processors/source'; import { view } from './processors/view'; import type Hexo from '../hex...
typescript
MIT
1fd997c3ad772ab7ed85b71b886d55248d92bb68
2026-01-04T15:50:29.521527Z
false
hexojs/hexo
https://github.com/hexojs/hexo/blob/1fd997c3ad772ab7ed85b71b886d55248d92bb68/lib/theme/view.ts
lib/theme/view.ts
import { dirname, extname, join } from 'path'; import { parse as yfm } from 'hexo-front-matter'; import Promise from 'bluebird'; import type Theme from '.'; import type Render from '../hexo/render'; import type { NodeJSLikeCallback } from '../types'; import type { Helper } from '../extend'; const assignIn = (target: a...
typescript
MIT
1fd997c3ad772ab7ed85b71b886d55248d92bb68
2026-01-04T15:50:29.521527Z
false
hexojs/hexo
https://github.com/hexojs/hexo/blob/1fd997c3ad772ab7ed85b71b886d55248d92bb68/lib/theme/processors/config.ts
lib/theme/processors/config.ts
import { Pattern } from 'hexo-util'; import type { _File } from '../../box'; import Theme from '..'; function process(file: _File) { if (file.type === 'delete') { (file.box as Theme).config = {}; return; } return file.render().then(result => { (file.box as Theme).config = result; this.log.debug(...
typescript
MIT
1fd997c3ad772ab7ed85b71b886d55248d92bb68
2026-01-04T15:50:29.521527Z
false
hexojs/hexo
https://github.com/hexojs/hexo/blob/1fd997c3ad772ab7ed85b71b886d55248d92bb68/lib/theme/processors/source.ts
lib/theme/processors/source.ts
import { Pattern } from 'hexo-util'; import * as common from '../../plugins/processor/common'; import type { _File } from '../../box'; function process(file: _File) { const Asset = this.model('Asset'); const id = file.source.substring(this.base_dir.length).replace(/\\/g, '/'); const { path } = file.params; con...
typescript
MIT
1fd997c3ad772ab7ed85b71b886d55248d92bb68
2026-01-04T15:50:29.521527Z
false
hexojs/hexo
https://github.com/hexojs/hexo/blob/1fd997c3ad772ab7ed85b71b886d55248d92bb68/lib/theme/processors/i18n.ts
lib/theme/processors/i18n.ts
import { Pattern } from 'hexo-util'; import { extname } from 'path'; import type { _File } from '../../box'; import type Theme from '..'; function process(file: _File) { const { path } = file.params; const ext = extname(path); const name = path.substring(0, path.length - ext.length); const { i18n } = (file.box...
typescript
MIT
1fd997c3ad772ab7ed85b71b886d55248d92bb68
2026-01-04T15:50:29.521527Z
false
hexojs/hexo
https://github.com/hexojs/hexo/blob/1fd997c3ad772ab7ed85b71b886d55248d92bb68/lib/theme/processors/view.ts
lib/theme/processors/view.ts
import { Pattern } from 'hexo-util'; import type { _File } from '../../box'; import type Theme from '..'; function process(file: _File): Promise<void> { const { path } = file.params; if (file.type === 'delete') { (file.box as Theme).removeView(path); return; } return file.read().then(result => { ...
typescript
MIT
1fd997c3ad772ab7ed85b71b886d55248d92bb68
2026-01-04T15:50:29.521527Z
false
hexojs/hexo
https://github.com/hexojs/hexo/blob/1fd997c3ad772ab7ed85b71b886d55248d92bb68/lib/extend/syntax_highlight.ts
lib/extend/syntax_highlight.ts
import type Hexo from '../hexo'; export interface HighlightOptions { lang: string | undefined, caption: string | undefined, lines_length?: number | undefined, // plugins/filter/before_post_render/backtick_code_block firstLineNumber?: string | number // plugins/tag/code.ts language_attr?: boolean | unde...
typescript
MIT
1fd997c3ad772ab7ed85b71b886d55248d92bb68
2026-01-04T15:50:29.521527Z
false
hexojs/hexo
https://github.com/hexojs/hexo/blob/1fd997c3ad772ab7ed85b71b886d55248d92bb68/lib/extend/deployer.ts
lib/extend/deployer.ts
import Promise from 'bluebird'; import type { NodeJSLikeCallback } from '../types'; import type Hexo from '../hexo'; interface StoreFunction { (this: Hexo, deployArg: { type: string; [key: string]: any }): Promise<any>; } interface Store { [key: string]: StoreFunction; } /** * A deployer helps users quickly depl...
typescript
MIT
1fd997c3ad772ab7ed85b71b886d55248d92bb68
2026-01-04T15:50:29.521527Z
false
hexojs/hexo
https://github.com/hexojs/hexo/blob/1fd997c3ad772ab7ed85b71b886d55248d92bb68/lib/extend/tag.ts
lib/extend/tag.ts
import { stripIndent } from 'hexo-util'; import { cyan, magenta, red, bold } from 'picocolors'; import { Environment } from 'nunjucks'; import Promise from 'bluebird'; import type { NodeJSLikeCallback } from '../types'; const rSwigRawFullBlock = /{% *raw *%}/; const rCodeTag = /<code[^<>]*>[\s\S]+?<\/code>/g; const es...
typescript
MIT
1fd997c3ad772ab7ed85b71b886d55248d92bb68
2026-01-04T15:50:29.521527Z
false
hexojs/hexo
https://github.com/hexojs/hexo/blob/1fd997c3ad772ab7ed85b71b886d55248d92bb68/lib/extend/renderer.ts
lib/extend/renderer.ts
import { extname } from 'path'; import Promise from 'bluebird'; import type { NodeJSLikeCallback } from '../types'; const getExtname = (str: string) => { if (typeof str !== 'string') return ''; const ext = extname(str) || str; return ext.startsWith('.') ? ext.slice(1) : ext; }; export interface StoreFunctionDa...
typescript
MIT
1fd997c3ad772ab7ed85b71b886d55248d92bb68
2026-01-04T15:50:29.521527Z
false
hexojs/hexo
https://github.com/hexojs/hexo/blob/1fd997c3ad772ab7ed85b71b886d55248d92bb68/lib/extend/helper.ts
lib/extend/helper.ts
import Hexo from '../hexo'; import { PageSchema } from '../types'; import * as hutil from 'hexo-util'; interface HexoContext extends Hexo { // get current page information // https://github.com/dimaslanjaka/hexo-renderers/blob/147340f6d03a8d3103e9589ddf86778ed7f9019b/src/helper/related-posts.ts#L106-L113 page?: ...
typescript
MIT
1fd997c3ad772ab7ed85b71b886d55248d92bb68
2026-01-04T15:50:29.521527Z
false
hexojs/hexo
https://github.com/hexojs/hexo/blob/1fd997c3ad772ab7ed85b71b886d55248d92bb68/lib/extend/processor.ts
lib/extend/processor.ts
import Promise from 'bluebird'; import { Pattern } from 'hexo-util'; import type File from '../box/file'; interface StoreFunction { (file: File | string): any; } type Store = { pattern: Pattern; process: StoreFunction; }[]; type patternType = Exclude<ConstructorParameters<typeof Pattern>[0], (str: string) => s...
typescript
MIT
1fd997c3ad772ab7ed85b71b886d55248d92bb68
2026-01-04T15:50:29.521527Z
false
hexojs/hexo
https://github.com/hexojs/hexo/blob/1fd997c3ad772ab7ed85b71b886d55248d92bb68/lib/extend/generator.ts
lib/extend/generator.ts
import Promise from 'bluebird'; import type { BaseGeneratorReturn, NodeJSLikeCallback, SiteLocals } from '../types'; type ReturnType = BaseGeneratorReturn | BaseGeneratorReturn[]; type GeneratorReturnType = ReturnType | Promise<ReturnType>; interface GeneratorFunction { (locals: SiteLocals, callback?: NodeJSLikeCal...
typescript
MIT
1fd997c3ad772ab7ed85b71b886d55248d92bb68
2026-01-04T15:50:29.521527Z
false
hexojs/hexo
https://github.com/hexojs/hexo/blob/1fd997c3ad772ab7ed85b71b886d55248d92bb68/lib/extend/filter.ts
lib/extend/filter.ts
import Promise from 'bluebird'; import { FilterOptions } from '../types'; const typeAlias = { pre: 'before_post_render', post: 'after_post_render', 'after_render:html': '_after_html_render' }; interface StoreFunction { (data?: any, ...args: any[]): any; priority?: number; } interface Store { [key: string...
typescript
MIT
1fd997c3ad772ab7ed85b71b886d55248d92bb68
2026-01-04T15:50:29.521527Z
false
hexojs/hexo
https://github.com/hexojs/hexo/blob/1fd997c3ad772ab7ed85b71b886d55248d92bb68/lib/extend/injector.ts
lib/extend/injector.ts
import { Cache } from 'hexo-util'; type Entry = 'head_begin' | 'head_end' | 'body_begin' | 'body_end'; type Store = { [key in Entry]: { [key: string]: Set<string>; }; }; /** * An injector is used to add static code snippet to the `<head>` or/and `<body>` of generated HTML files. * Hexo run injector before ...
typescript
MIT
1fd997c3ad772ab7ed85b71b886d55248d92bb68
2026-01-04T15:50:29.521527Z
false
hexojs/hexo
https://github.com/hexojs/hexo/blob/1fd997c3ad772ab7ed85b71b886d55248d92bb68/lib/extend/migrator.ts
lib/extend/migrator.ts
import Promise from 'bluebird'; import type { NodeJSLikeCallback } from '../types'; import type Hexo from '../hexo'; interface StoreFunction { (this: Hexo, args: any): Promise<any>; } interface Store { [key: string]: StoreFunction } /** * A migrator helps users migrate from other systems to Hexo. */ class Migr...
typescript
MIT
1fd997c3ad772ab7ed85b71b886d55248d92bb68
2026-01-04T15:50:29.521527Z
false
hexojs/hexo
https://github.com/hexojs/hexo/blob/1fd997c3ad772ab7ed85b71b886d55248d92bb68/lib/extend/console.ts
lib/extend/console.ts
import Promise from 'bluebird'; import abbrev from 'abbrev'; import type { NodeJSLikeCallback } from '../types'; import type Hexo from '../hexo'; type Option = Partial<{ usage: string; desc: string; init: boolean; arguments: { name: string; desc: string; }[]; options: { name: string; ...
typescript
MIT
1fd997c3ad772ab7ed85b71b886d55248d92bb68
2026-01-04T15:50:29.521527Z
false
hexojs/hexo
https://github.com/hexojs/hexo/blob/1fd997c3ad772ab7ed85b71b886d55248d92bb68/lib/extend/index.ts
lib/extend/index.ts
export { default as Console } from './console'; export { default as Deployer } from './deployer'; export { default as Filter } from './filter'; export { default as Generator } from './generator'; export { default as Helper } from './helper'; export { default as Highlight } from './syntax_highlight'; export { default as...
typescript
MIT
1fd997c3ad772ab7ed85b71b886d55248d92bb68
2026-01-04T15:50:29.521527Z
false
hexojs/hexo
https://github.com/hexojs/hexo/blob/1fd997c3ad772ab7ed85b71b886d55248d92bb68/lib/box/file.ts
lib/box/file.ts
import type Promise from 'bluebird'; import { readFile, readFileSync, stat, statSync, type ReadFileOptions } from 'hexo-fs'; import type fs from 'fs'; class File { /** * Full path of the file */ public source: string; /** * Relative path to the box of the file */ public path: string; /** * ...
typescript
MIT
1fd997c3ad772ab7ed85b71b886d55248d92bb68
2026-01-04T15:50:29.521527Z
false
hexojs/hexo
https://github.com/hexojs/hexo/blob/1fd997c3ad772ab7ed85b71b886d55248d92bb68/lib/box/index.ts
lib/box/index.ts
import { join, sep } from 'path'; import BlueBirdPromise from 'bluebird'; import File from './file'; import { Pattern, createSha1Hash } from 'hexo-util'; import { createReadStream, readdir, stat, watch } from 'hexo-fs'; import { magenta } from 'picocolors'; import { EventEmitter } from 'events'; import { isMatch, makeR...
typescript
MIT
1fd997c3ad772ab7ed85b71b886d55248d92bb68
2026-01-04T15:50:29.521527Z
false
colinhacks/zod
https://github.com/colinhacks/zod/blob/0cdc0b8597999fd9ca99767b912c1e82c1ff2d6c/vitest.config.ts
vitest.config.ts
import { dirname, resolve } from "node:path"; import { fileURLToPath } from "node:url"; import { type ViteUserConfig, defineConfig } from "vitest/config"; const __dirname = dirname(fileURLToPath(import.meta.url)); export default defineConfig({ resolve: { conditions: ["@zod/source", "default"], externalCondi...
typescript
MIT
0cdc0b8597999fd9ca99767b912c1e82c1ff2d6c
2026-01-04T15:50:20.611513Z
false
colinhacks/zod
https://github.com/colinhacks/zod/blob/0cdc0b8597999fd9ca99767b912c1e82c1ff2d6c/play.ts
play.ts
import * as z from "./packages/zod/src/v4/index.js"; z; const schema = z.object({ name: z.string() }).and(z.looseRecord(z.string().regex(/_phone$/), z.e164())); type _schema = z.infer<typeof schema>; // { name: string } & Record<string, string> & Record<string, number> z.e164();
typescript
MIT
0cdc0b8597999fd9ca99767b912c1e82c1ff2d6c
2026-01-04T15:50:20.611513Z
false
colinhacks/zod
https://github.com/colinhacks/zod/blob/0cdc0b8597999fd9ca99767b912c1e82c1ff2d6c/scripts/check-semver.ts
scripts/check-semver.ts
import { readFileSync } from "node:fs"; import { join } from "node:path"; import { fileURLToPath } from "node:url"; import semver from "semver"; const __dirname = fileURLToPath(new URL(".", import.meta.url)); const packageJsonPath = join(__dirname, "../packages/zod/package.json"); try { const packageJson = JSON.par...
typescript
MIT
0cdc0b8597999fd9ca99767b912c1e82c1ff2d6c
2026-01-04T15:50:20.611513Z
false
colinhacks/zod
https://github.com/colinhacks/zod/blob/0cdc0b8597999fd9ca99767b912c1e82c1ff2d6c/scripts/check-versions.ts
scripts/check-versions.ts
import { readFileSync } from "node:fs"; import { join } from "node:path"; import { fileURLToPath } from "node:url"; import { version } from "../packages/zod/src/v4/core/versions.js"; const __dirname = fileURLToPath(new URL(".", import.meta.url)); // Get zod package path const zodPackagePath = join(__dirname, "..", "p...
typescript
MIT
0cdc0b8597999fd9ca99767b912c1e82c1ff2d6c
2026-01-04T15:50:20.611513Z
false
colinhacks/zod
https://github.com/colinhacks/zod/blob/0cdc0b8597999fd9ca99767b912c1e82c1ff2d6c/scripts/write-stub-package-jsons.ts
scripts/write-stub-package-jsons.ts
#!/usr/bin/env tsx import { readdirSync, statSync, writeFileSync } from "node:fs"; import { join } from "node:path"; const STUB_PACKAGE_JSON_CONTENT = `{ "type": "module", "main": "./index.cjs", "module": "./index.js", "types": "./index.d.cts" } `; /** * Recursively find all index.d.cts files in a directo...
typescript
MIT
0cdc0b8597999fd9ca99767b912c1e82c1ff2d6c
2026-01-04T15:50:20.611513Z
false
colinhacks/zod
https://github.com/colinhacks/zod/blob/0cdc0b8597999fd9ca99767b912c1e82c1ff2d6c/scripts/fail-on-console.ts
scripts/fail-on-console.ts
import { afterAll, beforeAll } from "vitest"; const original = { ...console } as Record<string, any>; function thrower(method: string) { return (...args: any[]) => { throw new Error(`Unexpected console.${method} call: ${args.join(" ")}`); }; } beforeAll(() => { for (const method of ["log", "info", "warn", ...
typescript
MIT
0cdc0b8597999fd9ca99767b912c1e82c1ff2d6c
2026-01-04T15:50:20.611513Z
false
colinhacks/zod
https://github.com/colinhacks/zod/blob/0cdc0b8597999fd9ca99767b912c1e82c1ff2d6c/packages/integration/fixtures/ai-sdk/index.ts
packages/integration/fixtures/ai-sdk/index.ts
// This file tests that the Vercel AI SDK v5 works with Zod v4 without // "Type instantiation is excessively deep and possibly infinite" errors. import { openai } from "@ai-sdk/openai"; import { generateObject } from "ai"; import { z } from "zod"; const result = await generateObject({ model: openai("gpt-4.1-nano"),...
typescript
MIT
0cdc0b8597999fd9ca99767b912c1e82c1ff2d6c
2026-01-04T15:50:20.611513Z
false
colinhacks/zod
https://github.com/colinhacks/zod/blob/0cdc0b8597999fd9ca99767b912c1e82c1ff2d6c/packages/integration/fixtures/drizzle-zod/index.ts
packages/integration/fixtures/drizzle-zod/index.ts
// This file tests that drizzle-zod works with Zod v4 without // "Type instantiation is excessively deep and possibly infinite" errors. // See: https://github.com/colinhacks/zod/issues/XXXX import { pgEnum, pgTable, serial } from "drizzle-orm/pg-core"; import { createInsertSchema } from "drizzle-zod"; import * as z fr...
typescript
MIT
0cdc0b8597999fd9ca99767b912c1e82c1ff2d6c
2026-01-04T15:50:20.611513Z
false
colinhacks/zod
https://github.com/colinhacks/zod/blob/0cdc0b8597999fd9ca99767b912c1e82c1ff2d6c/packages/integration/fixtures/internal-types/index.ts
packages/integration/fixtures/internal-types/index.ts
// This fixture tests that Zod's built types have no internal errors // when compiled with skipLibCheck: false import { z } from "zod"; // Basic schema usage const userSchema = z.object({ name: z.string(), age: z.number().int().positive(), email: z.string().email(), tags: z.array(z.string()), role: z.enum([...
typescript
MIT
0cdc0b8597999fd9ca99767b912c1e82c1ff2d6c
2026-01-04T15:50:20.611513Z
false
colinhacks/zod
https://github.com/colinhacks/zod/blob/0cdc0b8597999fd9ca99767b912c1e82c1ff2d6c/packages/bench/lazy-box.ts
packages/bench/lazy-box.ts
import { randomString } from "./benchUtil.js"; import { metabench } from "./metabench.js"; export function lazyWithInternalProp<T>(getter: () => T) { return { __value: undefined as T, get value() { if (this.__value) return this.__value; const value = getter(); this.__value = value; re...
typescript
MIT
0cdc0b8597999fd9ca99767b912c1e82c1ff2d6c
2026-01-04T15:50:20.611513Z
false
colinhacks/zod
https://github.com/colinhacks/zod/blob/0cdc0b8597999fd9ca99767b912c1e82c1ff2d6c/packages/bench/datetime-regex.ts
packages/bench/datetime-regex.ts
import { metabench } from "./metabench.js"; const bench = metabench("datetime regex"); const DATA = "2021-01-01"; const MONTHS_31 = new Set([1, 3, 5, 7, 8, 10, 12]); const MONTHS_30 = new Set([4, 6, 9, 11]); const simpleDatetimeRegex = /^(\d{4})-(\d{2})-(\d{2})$/; const datetimeRegexNoLeapYearValidation = /^\d{4}-...
typescript
MIT
0cdc0b8597999fd9ca99767b912c1e82c1ff2d6c
2026-01-04T15:50:20.611513Z
false
colinhacks/zod
https://github.com/colinhacks/zod/blob/0cdc0b8597999fd9ca99767b912c1e82c1ff2d6c/packages/bench/object-creation.ts
packages/bench/object-creation.ts
import { metabench } from "./metabench.js"; class ZodFail { status = "fail"; constructor(public value: string) {} } const bench = metabench("object creation") .add("raw object", () => { const obj = { status: "fail", value: "this is a test" }; obj.value; }) .add("constructor", () => { const obj =...
typescript
MIT
0cdc0b8597999fd9ca99767b912c1e82c1ff2d6c
2026-01-04T15:50:20.611513Z
false
colinhacks/zod
https://github.com/colinhacks/zod/blob/0cdc0b8597999fd9ca99767b912c1e82c1ff2d6c/packages/bench/boolean.ts
packages/bench/boolean.ts
import { makeData, makeSchema } from "./benchUtil.js"; import { metabench } from "./metabench.js"; const { zod3, zod4 } = makeSchema((z) => z.boolean()); const DATA = makeData(10000, () => Math.random() > 0.5); const bench = metabench("z.boolean().parse", { zod3() { for (const _ of DATA) zod3.parse(_); }, z...
typescript
MIT
0cdc0b8597999fd9ca99767b912c1e82c1ff2d6c
2026-01-04T15:50:20.611513Z
false
colinhacks/zod
https://github.com/colinhacks/zod/blob/0cdc0b8597999fd9ca99767b912c1e82c1ff2d6c/packages/bench/object-safe.ts
packages/bench/object-safe.ts
import { metabench } from "./metabench.js"; import { DATA, zod3, zod4 } from "./object-setup.js"; const bench = metabench("small: z.object().safeParse", { zod3() { for (const _ of DATA) zod3.safeParse(_); }, zod4() { for (const _ of DATA) zod4.safeParse(_); }, }); await bench.run();
typescript
MIT
0cdc0b8597999fd9ca99767b912c1e82c1ff2d6c
2026-01-04T15:50:20.611513Z
false
colinhacks/zod
https://github.com/colinhacks/zod/blob/0cdc0b8597999fd9ca99767b912c1e82c1ff2d6c/packages/bench/jit-union.ts
packages/bench/jit-union.ts
import { makeData, randomPick, randomString } from "./benchUtil.js"; import { metabench } from "./metabench.js"; import * as z4 from "zod/mini"; const z4fields = { data1: z4.string(), data2: z4.string(), data3: z4.string(), data4: z4.string(), data5: z4.string(), data6: z4.string(), data7: z4.string(), ...
typescript
MIT
0cdc0b8597999fd9ca99767b912c1e82c1ff2d6c
2026-01-04T15:50:20.611513Z
false
colinhacks/zod
https://github.com/colinhacks/zod/blob/0cdc0b8597999fd9ca99767b912c1e82c1ff2d6c/packages/bench/safe.ts
packages/bench/safe.ts
import { randomString } from "./benchUtil.js"; import { benchWithData } from "./metabench.js"; class ZodFail { status = "fail"; constructor(public value: string) { // super(); } } function makeSuccess(value: unknown) { return { status: "success", value }; } function makeFail(value: unknown) { return { s...
typescript
MIT
0cdc0b8597999fd9ca99767b912c1e82c1ff2d6c
2026-01-04T15:50:20.611513Z
false
colinhacks/zod
https://github.com/colinhacks/zod/blob/0cdc0b8597999fd9ca99767b912c1e82c1ff2d6c/packages/bench/init.ts
packages/bench/init.ts
import * as z4 from "zod"; import * as z3 from "zod3"; import * as z4lib from "zod4"; import { metabench } from "./metabench.js"; const DATA = Array.from({ length: 1000 }, () => Object.freeze({ number: 1, negNumber: -1, maxNumber: Number.MAX_VALUE, string: "string", longString: "Lorem ipsum...
typescript
MIT
0cdc0b8597999fd9ca99767b912c1e82c1ff2d6c
2026-01-04T15:50:20.611513Z
false
colinhacks/zod
https://github.com/colinhacks/zod/blob/0cdc0b8597999fd9ca99767b912c1e82c1ff2d6c/packages/bench/number.ts
packages/bench/number.ts
import { makeData, makeSchema } from "./benchUtil.js"; import { metabench } from "./metabench.js"; const { zod3, zod4 } = makeSchema((z) => z.number()); const DATA = makeData(10000, () => Math.random()); const bench = metabench("z.number().parse", { zod3() { for (const _ of DATA) zod3.parse(_); }, zod4() { ...
typescript
MIT
0cdc0b8597999fd9ca99767b912c1e82c1ff2d6c
2026-01-04T15:50:20.611513Z
false
colinhacks/zod
https://github.com/colinhacks/zod/blob/0cdc0b8597999fd9ca99767b912c1e82c1ff2d6c/packages/bench/error-handling.ts
packages/bench/error-handling.ts
import { makeData } from "./benchUtil.js"; import { metabench } from "./metabench.js"; import * as z from "zod/v3"; import * as z4 from "zod/v4"; const a = z4.object({ a: z4.string() }); const b = z.object({ a: z.string() }); const DATA = makeData(10000, () => ({ b: `${Math.random()}` })); const bench = metabench("...
typescript
MIT
0cdc0b8597999fd9ca99767b912c1e82c1ff2d6c
2026-01-04T15:50:20.611513Z
false
colinhacks/zod
https://github.com/colinhacks/zod/blob/0cdc0b8597999fd9ca99767b912c1e82c1ff2d6c/packages/bench/single-item-union.ts
packages/bench/single-item-union.ts
import { randomString, zod4, zodNext } from "./benchUtil.js"; import { metabench } from "./metabench.js"; console.log("Single item union"); const z4LibSchema = zod4.union([zod4.object({ value: zod4.string() })]); const z4Schema = zodNext.union([zodNext.object({ value: zodNext.string() })]); const DATA = Array.from(...
typescript
MIT
0cdc0b8597999fd9ca99767b912c1e82c1ff2d6c
2026-01-04T15:50:20.611513Z
false
colinhacks/zod
https://github.com/colinhacks/zod/blob/0cdc0b8597999fd9ca99767b912c1e82c1ff2d6c/packages/bench/array.ts
packages/bench/array.ts
import { makeData, makeSchema, randomString } from "./benchUtil.js"; import { metabench } from "./metabench.js"; const { zod3, zod4 } = makeSchema((z) => z.array(z.string())); const DATA = makeData(1000, () => Array.from({ length: 3 }, () => randomString(10))); // make sure they're working console.log(zod3.parse(DATA...
typescript
MIT
0cdc0b8597999fd9ca99767b912c1e82c1ff2d6c
2026-01-04T15:50:20.611513Z
false
colinhacks/zod
https://github.com/colinhacks/zod/blob/0cdc0b8597999fd9ca99767b912c1e82c1ff2d6c/packages/bench/string.ts
packages/bench/string.ts
import { makeData, makeSchema } from "./benchUtil.js"; import { metabench } from "./metabench.js"; const { zod3, zod4 } = makeSchema((z) => z.string()); const DATA = makeData(10000, () => `${Math.random()}`); const bench = metabench("z.string().parse", { zod3() { for (const _ of DATA) zod3.parse(_); }, zod4...
typescript
MIT
0cdc0b8597999fd9ca99767b912c1e82c1ff2d6c
2026-01-04T15:50:20.611513Z
false
colinhacks/zod
https://github.com/colinhacks/zod/blob/0cdc0b8597999fd9ca99767b912c1e82c1ff2d6c/packages/bench/union.ts
packages/bench/union.ts
import { makeSchema } from "./benchUtil.js"; import { metabench } from "./metabench.js"; const { zod3, zod4 } = makeSchema((z) => { const aSchema = z.object({ type: z.literal("a"), }); const bSchema = z.object({ type: z.literal("b"), }); const cSchema = z.object({ type: z.literal("c"), }); ...
typescript
MIT
0cdc0b8597999fd9ca99767b912c1e82c1ff2d6c
2026-01-04T15:50:20.611513Z
false
colinhacks/zod
https://github.com/colinhacks/zod/blob/0cdc0b8597999fd9ca99767b912c1e82c1ff2d6c/packages/bench/datetime.ts
packages/bench/datetime.ts
import { makeData, makeSchema } from "./benchUtil.js"; import { metabench } from "./metabench.js"; const { zod3, zod4 } = makeSchema((z) => z.string().datetime()); const DATA = makeData(10000, () => new Date().toISOString()); const bench = metabench("z.string().datetime().parse", { zod3() { for (const _ of DATA...
typescript
MIT
0cdc0b8597999fd9ca99767b912c1e82c1ff2d6c
2026-01-04T15:50:20.611513Z
false
colinhacks/zod
https://github.com/colinhacks/zod/blob/0cdc0b8597999fd9ca99767b912c1e82c1ff2d6c/packages/bench/object-setup.ts
packages/bench/object-setup.ts
import { makeData, makeSchema } from "./benchUtil.js"; // import { metabench } from "./metabench.js"; export const { zod3, zod4 } = makeSchema((z) => z.object({ string: z.string(), boolean: z.boolean(), number: z.number(), }) ); // biome-ignore lint/style/noVar: <explanation> // biome-ignore lint/corr...
typescript
MIT
0cdc0b8597999fd9ca99767b912c1e82c1ff2d6c
2026-01-04T15:50:20.611513Z
false
colinhacks/zod
https://github.com/colinhacks/zod/blob/0cdc0b8597999fd9ca99767b912c1e82c1ff2d6c/packages/bench/single-element-enum.ts
packages/bench/single-element-enum.ts
import { zod4, zodNext } from "./benchUtil.js"; import { metabench } from "./metabench.js"; console.log("Single-element enum benchmarking"); const z4LibSchema = zod4.enum(["a"]); const z4Schema = zodNext.enum(["a"]); const DATA = Array.from({ length: 10000 }, () => "a"); console.log(z4Schema.parse(DATA[0])); conso...
typescript
MIT
0cdc0b8597999fd9ca99767b912c1e82c1ff2d6c
2026-01-04T15:50:20.611513Z
false
colinhacks/zod
https://github.com/colinhacks/zod/blob/0cdc0b8597999fd9ca99767b912c1e82c1ff2d6c/packages/bench/discriminated-union.ts
packages/bench/discriminated-union.ts
import { makeData, randomPick, randomString } from "./benchUtil.js"; import { metabench } from "./metabench.js"; import * as z3 from "zod/v3"; import * as z4 from "zod/v4"; import * as z4lib from "zod4/v4"; const z3fields = { data1: z3.string(), data2: z3.string(), data3: z3.string(), // data4: z3.string(), ...
typescript
MIT
0cdc0b8597999fd9ca99767b912c1e82c1ff2d6c
2026-01-04T15:50:20.611513Z
false
colinhacks/zod
https://github.com/colinhacks/zod/blob/0cdc0b8597999fd9ca99767b912c1e82c1ff2d6c/packages/bench/safeparse.ts
packages/bench/safeparse.ts
import * as z from "zod/v4"; import { metabench } from "./metabench.js"; const schema = z.object({ string: z.string(), boolean: z.boolean(), number: z.number(), }); const DATA = Array.from({ length: 1000 }, () => Object.freeze({ // number: Math.random(), // string: `${Math.random()}`, // boolean: ...
typescript
MIT
0cdc0b8597999fd9ca99767b912c1e82c1ff2d6c
2026-01-04T15:50:20.611513Z
false
colinhacks/zod
https://github.com/colinhacks/zod/blob/0cdc0b8597999fd9ca99767b912c1e82c1ff2d6c/packages/bench/object-moltar-jitless.ts
packages/bench/object-moltar-jitless.ts
import * as z4 from "zod/v4"; import * as z3 from "zod3"; import * as z4lib from "zod4/v4"; import { metabench } from "./metabench.js"; z4.config({ jitless: true, }); z4lib.config({ jitless: true, }); const z3Schema = z3.strictObject({ number: z3.number(), negNumber: z3.number(), maxNumber: z3.number(), ...
typescript
MIT
0cdc0b8597999fd9ca99767b912c1e82c1ff2d6c
2026-01-04T15:50:20.611513Z
false
colinhacks/zod
https://github.com/colinhacks/zod/blob/0cdc0b8597999fd9ca99767b912c1e82c1ff2d6c/packages/bench/object.ts
packages/bench/object.ts
import * as v from "valibot"; import * as z4 from "zod/v4"; import * as z3 from "zod3"; import { metabench } from "./metabench.js"; const z3Schema = z3.object({ string: z3.string(), boolean: z3.boolean(), number: z3.number(), }); const z4Schema = z4.object({ string: z4.string(), boolean: z4.boolean(), num...
typescript
MIT
0cdc0b8597999fd9ca99767b912c1e82c1ff2d6c
2026-01-04T15:50:20.611513Z
false
colinhacks/zod
https://github.com/colinhacks/zod/blob/0cdc0b8597999fd9ca99767b912c1e82c1ff2d6c/packages/bench/object-moltar.ts
packages/bench/object-moltar.ts
import * as z4 from "zod/v4"; import * as z3 from "zod3"; import * as z4lib from "zod4/v4"; import { metabench } from "./metabench.js"; const z3Schema = z3.strictObject({ number: z3.number(), negNumber: z3.number(), maxNumber: z3.number(), string: z3.string(), longString: z3.string(), boolean: z3.boolean()...
typescript
MIT
0cdc0b8597999fd9ca99767b912c1e82c1ff2d6c
2026-01-04T15:50:20.611513Z
false
colinhacks/zod
https://github.com/colinhacks/zod/blob/0cdc0b8597999fd9ca99767b912c1e82c1ff2d6c/packages/bench/benchUtil.ts
packages/bench/benchUtil.ts
import * as zod3 from "zod3"; import * as zod4 from "zod4"; import * as zodNext from "../zod/src/index.js"; export { zod3, zod4, zodNext }; export function makeSchema<T>(factory: (z: typeof zod4) => T) { return { zod3: factory(zod3 as any) as T, zod4: factory(zod4 as any) as T, // zod4Ts: factory(zodNewT...
typescript
MIT
0cdc0b8597999fd9ca99767b912c1e82c1ff2d6c
2026-01-04T15:50:20.611513Z
false
colinhacks/zod
https://github.com/colinhacks/zod/blob/0cdc0b8597999fd9ca99767b912c1e82c1ff2d6c/packages/bench/key-iteration.ts
packages/bench/key-iteration.ts
import { metabench } from "./metabench.js"; const DATA_WITH_SYMBOLS = Array.from({ length: 1000 }, () => { return { [Symbol.for("comet")]: 0, str: 0, 773: 0, 0: 0, "-1": 0, 8: 0, "second str": 0, }; }); const DATA_WITHOUT_SYMBOLS = Array.from({ length: 1000 }, () => { return { st...
typescript
MIT
0cdc0b8597999fd9ca99767b912c1e82c1ff2d6c
2026-01-04T15:50:20.611513Z
false
colinhacks/zod
https://github.com/colinhacks/zod/blob/0cdc0b8597999fd9ca99767b912c1e82c1ff2d6c/packages/bench/index.ts
packages/bench/index.ts
import { execa } from "execa"; const $ = execa({ stdout: "inherit", stderr: "inherit" }); async function run() { const files = process.argv[2].split(",").map((file) => import.meta.resolve(`./${file}`).replace("file://", "")); for (const file of files) { await $`pnpm tsx --conditions @zod/source ${file}`; ...
typescript
MIT
0cdc0b8597999fd9ca99767b912c1e82c1ff2d6c
2026-01-04T15:50:20.611513Z
false
colinhacks/zod
https://github.com/colinhacks/zod/blob/0cdc0b8597999fd9ca99767b912c1e82c1ff2d6c/packages/bench/ipv4-regex.ts
packages/bench/ipv4-regex.ts
import { metabench } from "./metabench.js"; const DATA = "127.0.0.1"; const ipv4RegexA = /^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/; const ipv4RegexB = /^(?:(?:(?=(25[0-5]))\1|(?=(2[0-4][0-9]))\2|(?=(1[0-9]{2}))\3|(?=([0-9]{1,2}))\4)\.){3}(?:(?=(...
typescript
MIT
0cdc0b8597999fd9ca99767b912c1e82c1ff2d6c
2026-01-04T15:50:20.611513Z
false
colinhacks/zod
https://github.com/colinhacks/zod/blob/0cdc0b8597999fd9ca99767b912c1e82c1ff2d6c/packages/bench/object-async.ts
packages/bench/object-async.ts
import { metabench } from "./metabench.js"; import { DATA, zod3, zod4 } from "./object-setup.js"; const bench = metabench("small: z.object().parseAsync", { async zod3() { for (const _ of DATA) await zod3.parseAsync(_); }, async zod4() { for (const _ of DATA) await zod4.parseAsync(_); }, }); await benc...
typescript
MIT
0cdc0b8597999fd9ca99767b912c1e82c1ff2d6c
2026-01-04T15:50:20.611513Z
false