repo_name string | dataset string | owner string | lang string | func_name string | code string | docstring string | url string | sha string |
|---|---|---|---|---|---|---|---|---|
bisheng | github_2023 | dataelement | typescript | handleSaveVersion | const handleSaveVersion = async () => {
// 保存当前版本
captureAndAlertRequestErrorHoc(updateVersion(version.id, { name: version.name, description: '', data: flow.data }).then(_ => {
setFlow('versionChange', { ...flow }) // 更新clone flow,避免触发diff不同
_ && message({
varian... | // 保存版本 | https://github.com/dataelement/bisheng/blob/be229e3e63eabfacbd35ae4971485980932f7227/src/frontend/src/pages/BuildPage/skills/editSkill/Header.tsx#L97-L108 | be229e3e63eabfacbd35ae4971485980932f7227 |
bisheng | github_2023 | dataelement | typescript | handleSaveAndClose | const handleSaveAndClose = async () => {
setFlow('leave and save', { ...flow })
if (isOnlineVersion) {
handleSaveNewVersion()
blocker.reset?.()
} else {
await captureAndAlertRequestErrorHoc(updateVersion(version.id, { name: version.name, description: '', data:... | // 离开并保存 | https://github.com/dataelement/bisheng/blob/be229e3e63eabfacbd35ae4971485980932f7227/src/frontend/src/pages/BuildPage/skills/editSkill/Header.tsx#L112-L121 | be229e3e63eabfacbd35ae4971485980932f7227 |
bisheng | github_2023 | dataelement | typescript | handleChangName | const handleChangName = (id, name) => {
captureAndAlertRequestErrorHoc(updateVersion(id, { name, description: '', data: null }))
// 乐观更新
setVersions(versions.map(version => {
if (version.id === id) {
version.name = name;
}
return version;
... | // 修改名字 | https://github.com/dataelement/bisheng/blob/be229e3e63eabfacbd35ae4971485980932f7227/src/frontend/src/pages/BuildPage/skills/editSkill/Header.tsx#L294-L303 | be229e3e63eabfacbd35ae4971485980932f7227 |
bisheng | github_2023 | dataelement | typescript | onKeyDown | const onKeyDown = (event: KeyboardEvent) => {
if (event.target.tagName === 'INPUT') return // 排除输入框内复制粘贴
if (
(event.ctrlKey || event.metaKey) &&
event.key === "c" &&
lastSelection
) {
event.preventDefault();
setLastCopiedSelection(cloneDeep(lastSelection));
... | // this effect is used to attach the global event handlers | https://github.com/dataelement/bisheng/blob/be229e3e63eabfacbd35ae4971485980932f7227/src/frontend/src/pages/BuildPage/skills/editSkill/PageComponent/index.tsx#L466-L501 | be229e3e63eabfacbd35ae4971485980932f7227 |
bisheng | github_2023 | dataelement | typescript | init | const init = async () => {
const isV1 = version === 'v1';
if (type === AppNumType.SKILL) {
setAssistant(null)
setWorkflow(null)
const _flow = await getFlowApi(id, version)
await build(_flow, chatId)
if (isV1) {
loadHistoryMsg(_... | // console.log('autoRun :>> ', autoRun); | https://github.com/dataelement/bisheng/blob/be229e3e63eabfacbd35ae4971485980932f7227/src/frontend/src/pages/ChatAppPage/components/ChatPanne.tsx#L44-L105 | be229e3e63eabfacbd35ae4971485980932f7227 |
bisheng | github_2023 | dataelement | typescript | getWsParamData | const getWsParamData = (action, msg) => {
if (type === AppNumType.SKILL) {
const _flow = flowRef.current
let inputs = tabsState[_flow.id].formKeysData.input_keys;
const input = inputs.find((el: any) => !el.type)
const inputKey = input ? Object.keys(input)[0] : '';... | // 依赖 chatId更新闭包,不依赖 flow | https://github.com/dataelement/bisheng/blob/be229e3e63eabfacbd35ae4971485980932f7227/src/frontend/src/pages/ChatAppPage/components/ChatPanne.tsx#L122-L158 | be229e3e63eabfacbd35ae4971485980932f7227 |
bisheng | github_2023 | dataelement | typescript | streamNodeData | async function streamNodeData(flow: FlowType, chatId: string) {
// Step 1: Make a POST request to send the flow data and receive a unique session ID
const { flowId } = await postBuildInit({ flow, chatId });
// Step 2: Use the session ID to establish an SSE connection using EventSource
le... | // SSE 服务端推送 | https://github.com/dataelement/bisheng/blob/be229e3e63eabfacbd35ae4971485980932f7227/src/frontend/src/pages/ChatAppPage/components/ChatPanne.tsx#L304-L363 | be229e3e63eabfacbd35ae4971485980932f7227 |
bisheng | github_2023 | dataelement | typescript | enforceMinimumLoadingTime | async function enforceMinimumLoadingTime(
startTime: number,
minimumLoadingTime: number
) {
const elapsedTime = Date.now() - startTime;
const remainingTime = minimumLoadingTime - elapsedTime;
if (remainingTime > 0) {
return new Promise((resolve) => setTimeout(res... | // 延时器 | https://github.com/dataelement/bisheng/blob/be229e3e63eabfacbd35ae4971485980932f7227/src/frontend/src/pages/ChatAppPage/components/ChatPanne.tsx#L366-L376 | be229e3e63eabfacbd35ae4971485980932f7227 |
bisheng | github_2023 | dataelement | typescript | handleAddKeyword | const handleAddKeyword = (str: string) => {
setEditCustomKey(false)
if (!str) return
if (inputRef.current) inputRef.current.value = ''
onAdd(str)
} | // 移动端 e | https://github.com/dataelement/bisheng/blob/be229e3e63eabfacbd35ae4971485980932f7227/src/frontend/src/pages/ChatAppPage/components/ResouceModal.tsx#L85-L90 | be229e3e63eabfacbd35ae4971485980932f7227 |
bisheng | github_2023 | dataelement | typescript | handleOpenInput | const handleOpenInput = () => {
setEditCustomKey(true)
setTimeout(() => document.getElementById('taginput')?.focus(), 0);
} | // input show | https://github.com/dataelement/bisheng/blob/be229e3e63eabfacbd35ae4971485980932f7227/src/frontend/src/pages/ChatAppPage/components/ResouceModal.tsx#L113-L116 | be229e3e63eabfacbd35ae4971485980932f7227 |
bisheng | github_2023 | dataelement | typescript | handleDownExcle | const handleDownExcle = () => {
const data = [['测试用例', ...mulitVersionFlow.map(version => version.name)]];
questions.forEach((_, index) => {
const rowData = [_.q]
mulitVersionFlow.forEach(version => {
rowData.push(cellRefs[`${index}-${version.id}`].current.getDat... | // 导出结果(excle) | https://github.com/dataelement/bisheng/blob/be229e3e63eabfacbd35ae4971485980932f7227/src/frontend/src/pages/DiffFlowPage/components/RunTest.tsx#L89-L125 | be229e3e63eabfacbd35ae4971485980932f7227 |
bisheng | github_2023 | dataelement | typescript | streamNodeData | async function streamNodeData(flow: FlowType, chatId: string) {
let res = null
// Step 1: Make a POST request to send the flow data and receive a unique session ID
const _flow = { ...flow, id: flow.flow_id }
const { flowId } = await postBuildInit({ flow: _flow, versionId: flow.id });
... | // SSE 服务端推送 | https://github.com/dataelement/bisheng/blob/be229e3e63eabfacbd35ae4971485980932f7227/src/frontend/src/pages/DiffFlowPage/components/RunTest.tsx#L253-L309 | be229e3e63eabfacbd35ae4971485980932f7227 |
bisheng | github_2023 | dataelement | typescript | enforceMinimumLoadingTime | async function enforceMinimumLoadingTime(
startTime: number,
minimumLoadingTime: number
) {
const elapsedTime = Date.now() - startTime;
const remainingTime = minimumLoadingTime - elapsedTime;
if (remainingTime > 0) {
return new Promise((resolve) => setTimeout(res... | // 延时器 | https://github.com/dataelement/bisheng/blob/be229e3e63eabfacbd35ae4971485980932f7227/src/frontend/src/pages/DiffFlowPage/components/RunTest.tsx#L312-L322 | be229e3e63eabfacbd35ae4971485980932f7227 |
bisheng | github_2023 | dataelement | typescript | loadchunks | const loadchunks = async (fileValue) => {
if (!fileValue) return
setLoading(true)
setFileValue(fileValue)
fileValueRef.current = fileValue
previewFileSplitApi({ ...paramsRef.current, file_path: fileValue, cache: !!fileCachesRef.current[fileValue] }).then(res => {
setL... | // 加载文件分段结果 | https://github.com/dataelement/bisheng/blob/be229e3e63eabfacbd35ae4971485980932f7227/src/frontend/src/pages/KnowledgePage/components/FileUploadParagraphs.tsx#L57-L72 | be229e3e63eabfacbd35ae4971485980932f7227 |
bisheng | github_2023 | dataelement | typescript | handleSaveFiles | const handleSaveFiles = () => {
const [fileCount, files, failFiles] = uploadRef.current?.getUploadResult()
if (!files.length) return message({ variant: 'error', description: t('code.selectFileToUpload', { ns: 'bs' }) })
onNext({ fileCount, files, failFiles })
} | // useEffect(() => { | https://github.com/dataelement/bisheng/blob/be229e3e63eabfacbd35ae4971485980932f7227/src/frontend/src/pages/KnowledgePage/components/FileUploadStep1.tsx#L20-L24 | be229e3e63eabfacbd35ae4971485980932f7227 |
bisheng | github_2023 | dataelement | typescript | handlePreview | const handlePreview = () => {
const params = getParams(size, overlap)
onPreview(params, fileInfo.files)
} | // 预览 | https://github.com/dataelement/bisheng/blob/be229e3e63eabfacbd35ae4971485980932f7227/src/frontend/src/pages/KnowledgePage/components/FileUploadStep2.tsx#L113-L116 | be229e3e63eabfacbd35ae4971485980932f7227 |
bisheng | github_2023 | dataelement | typescript | handleMarkAfter | const handleMarkAfter = () => {
if (status === LabelStatus.Unlabeled) {
changeMarkStatus(LabelStatus.Labeled)
}
} | // 完成标注 | https://github.com/dataelement/bisheng/blob/be229e3e63eabfacbd35ae4971485980932f7227/src/frontend/src/pages/LabelPage/taskAppChats.tsx#L122-L126 | be229e3e63eabfacbd35ae4971485980932f7227 |
bisheng | github_2023 | dataelement | typescript | uploadFileWithProgress | const uploadFileWithProgress = async (file, callback): Promise<any> => {
try {
const formData = new FormData();
formData.append(fileKey, file);
const config = {
headers: { 'Content-Type': 'multipart/form-data;charset=utf-8' },
onUploadProgress... | // 上传函数 | https://github.com/dataelement/bisheng/blob/be229e3e63eabfacbd35ae4971485980932f7227/src/frontend/src/pages/ModelPage/components/UploadModal.tsx#L147-L176 | be229e3e63eabfacbd35ae4971485980932f7227 |
bisheng | github_2023 | dataelement | typescript | handleCheck | const handleCheck = (index, bool, id) => {
captureAndAlertRequestErrorHoc(changeLLmServerStatus(id, bool))
data[index].models = data[index].models.map(el => el.id === id ? { ...el, online: bool } : el)
setData([...data])
} | // off&online | https://github.com/dataelement/bisheng/blob/be229e3e63eabfacbd35ae4971485980932f7227/src/frontend/src/pages/ModelPage/manage/index.tsx#L114-L118 | be229e3e63eabfacbd35ae4971485980932f7227 |
bisheng | github_2023 | dataelement | typescript | handlerChecked | const handlerChecked = (id) => {
setValue(val => {
const index = val.indexOf(id)
index === -1 ? val.push(id) : val.splice(index, 1)
return [...val]
})
// 已选项上浮
const checked = options.filter(o => _value.includes(o.id))
const uncheck = options.f... | // 点击 checkbox | https://github.com/dataelement/bisheng/blob/be229e3e63eabfacbd35ae4971485980932f7227/src/frontend/src/pages/SystemPage/components/Users.tsx#L34-L44 | be229e3e63eabfacbd35ae4971485980932f7227 |
bisheng | github_2023 | dataelement | typescript | reset | const reset = () => {
setValue([])
setSearchKey('')
} | // 重置 | https://github.com/dataelement/bisheng/blob/be229e3e63eabfacbd35ae4971485980932f7227/src/frontend/src/pages/SystemPage/components/Users.tsx#L56-L59 | be229e3e63eabfacbd35ae4971485980932f7227 |
bisheng | github_2023 | dataelement | typescript | handleDelete | const handleDelete = (user) => {
bsConfirm({
title: `${t('prompt')}!`,
desc: t('system.confirmDisable'),
okTxt: t('disable'),
onOk(next) {
captureAndAlertRequestErrorHoc(disableUserApi(user.user_id, 1).then(res => {
reload()
... | // 禁用确认 | https://github.com/dataelement/bisheng/blob/be229e3e63eabfacbd35ae4971485980932f7227/src/frontend/src/pages/SystemPage/components/Users.tsx#L95-L107 | be229e3e63eabfacbd35ae4971485980932f7227 |
bisheng | github_2023 | dataelement | typescript | handleGroupChecked | const handleGroupChecked = (values) => {
setUserGroups(values)
} | // 已选项上浮 | https://github.com/dataelement/bisheng/blob/be229e3e63eabfacbd35ae4971485980932f7227/src/frontend/src/pages/SystemPage/components/Users.tsx#L135-L137 | be229e3e63eabfacbd35ae4971485980932f7227 |
bisheng | github_2023 | dataelement | typescript | handleHSLtoStr | const handleHSLtoStr = (hsl) => {
return `${hsl.h} ${hsl.s * 100}% ${hsl.l * 100}%`
} | // hsl -> '220 98% 95%' | https://github.com/dataelement/bisheng/blob/be229e3e63eabfacbd35ae4971485980932f7227/src/frontend/src/pages/SystemPage/theme/index.tsx#L72-L74 | be229e3e63eabfacbd35ae4971485980932f7227 |
bisheng | github_2023 | dataelement | typescript | runTest | const runTest = ({ questions, questionIndexs, nodeId, versionIds, inputs, refs }) => {
// loading
// console.log(refs, 222);
const runIds = []
questionIndexs.forEach(qIndex => {
versionIds.forEach(versionId => {
refs[`${qIndex}-${versionId}`].current.loading()
runIds.push... | /**
* 运行测试用例
* @param questions 所有问题列表
* @param questionIndexs 问题索引
* @param nodeId 节点id
* @param versionIds 版本id
* @param refs 单元格ref
*/ | https://github.com/dataelement/bisheng/blob/be229e3e63eabfacbd35ae4971485980932f7227/src/frontend/src/store/diffFlowStore.tsx#L204-L267 | be229e3e63eabfacbd35ae4971485980932f7227 |
bisheng | github_2023 | dataelement | typescript | loadData | const loadData = () => {
!cancelLoadingWhenReload && setLoading(true);
const requestId = ++requestIdRef.current
apiFun({ ...page, ...paramRef.current }).then(res => {
console.log('res :>> ', res);
if (requestId !== requestIdRef.current) return
if (!("total" in... | // 控制请求响应顺序 | https://github.com/dataelement/bisheng/blob/be229e3e63eabfacbd35ae4971485980932f7227/src/frontend/src/util/hook.ts#L78-L93 | be229e3e63eabfacbd35ae4971485980932f7227 |
standard-webhooks | github_2023 | standard-webhooks | typescript | assert | function assert(expr: unknown, msg = ""): asserts expr {
if (!expr) {
throw new Error(msg);
}
} | // Copyright 2018-2022 the Deno authors. All rights reserved. MIT license. | https://github.com/standard-webhooks/standard-webhooks/blob/c1b941e3a0552302c2be4309c9a81868248e14c1/libraries/javascript/src/timing_safe_equal.ts#L5-L9 | c1b941e3a0552302c2be4309c9a81868248e14c1 |
ai-comic-factory | github_2023 | jbilcke-hf | typescript | usePageOrientation | const usePageOrientation = () => {
useEffect(() => {
const updatePageOrientation = () => {
const pages = document.querySelectorAll(".comic-page");
const styleEl = document.createElement("style");
// Append style element to the head
document.head.appendChild(styleEl);
// Get the sty... | /**
* This will turn the page in portrait or landscape depending on the number of pages
*/ | https://github.com/jbilcke-hf/ai-comic-factory/blob/eea04ba1b30d222d014341c6cb354acf3239b722/src/lib/usePageOrientation.ts#L6-L36 | eea04ba1b30d222d014341c6cb354acf3239b722 |
datastar | github_2023 | starfederation | typescript | nestedValues | function nestedValues(
signal: NestedSignal,
onlyPublic = false,
): Record<string, any> {
const kv: Record<string, any> = {}
for (const key in signal) {
if (Object.hasOwn(signal, key)) {
if (onlyPublic && key.startsWith('_')) {
continue
}
const value = signal[key]
if (value i... | // If onlyPublic is true, only signals not starting with an underscore are included | https://github.com/starfederation/datastar/blob/fa679aa40c46bdd08d3e5230c4d4465ea795ba45/library/src/engine/signals.ts#L20-L39 | fa679aa40c46bdd08d3e5230c4d4465ea795ba45 |
datastar | github_2023 | starfederation | typescript | nestedSubset | function nestedSubset(original: NestedValues, ...keys: string[]): NestedValues {
const subset: NestedValues = {}
for (const key of keys) {
const parts = key.split('.')
let subOriginal = original
let subSubset = subset
for (let i = 0; i < parts.length - 1; i++) {
const part = parts[i]
if ... | // Recursive function to subset a nested object, each key is a dot-delimited path | https://github.com/starfederation/datastar/blob/fa679aa40c46bdd08d3e5230c4d4465ea795ba45/library/src/engine/signals.ts#L117-L138 | fa679aa40c46bdd08d3e5230c4d4465ea795ba45 |
datastar | github_2023 | starfederation | typescript | onPageshow | const onPageshow = (ev: PageTransitionEvent) => {
if (!ev.persisted) return
el2sig()
} | /*
* The signal value needs to be updated after the "pageshow" event.
* Sometimes, the browser might populate inputs with previous values
* when navigating between pages using the back/forward navigation.
*
* For more information, read about bfcache:
* https://web.dev/articles/bfcache
... | https://github.com/starfederation/datastar/blob/fa679aa40c46bdd08d3e5230c4d4465ea795ba45/library/src/plugins/official/dom/attributes/bind.ts#L186-L189 | fa679aa40c46bdd08d3e5230c4d4465ea795ba45 |
datastar | github_2023 | starfederation | typescript | create | async function create() {
curRequestController = new AbortController()
try {
const response = await fetch(input, {
...rest,
headers,
signal: curRequestController.signal,
})
await onopen(response)
await getBytes(
response.body!,
... | // response: Response | https://github.com/starfederation/datastar/blob/fa679aa40c46bdd08d3e5230c4d4465ea795ba45/library/src/vendored/fetch-event-source.ts#L318-L381 | fa679aa40c46bdd08d3e5230c4d4465ea795ba45 |
datastar | github_2023 | starfederation | typescript | batch | function batch<T>(fn: () => T): T {
if (batchDepth > 0) {
return fn()
}
/*@__INLINE__**/ startBatch()
try {
return fn()
} finally {
endBatch()
}
} | /**
* Combine multiple value updates into one "commit" at the end of the provided callback.
*
* Batches can be nested and changes are only flushed once the outermost batch callback
* completes.
*
* Accessing a signal that has been modified within a batch will reflect its updated
* value.
*
* @param fn The call... | https://github.com/starfederation/datastar/blob/fa679aa40c46bdd08d3e5230c4d4465ea795ba45/library/src/vendored/preact-core.ts#L99-L109 | fa679aa40c46bdd08d3e5230c4d4465ea795ba45 |
datastar | github_2023 | starfederation | typescript | untracked | function untracked<T>(fn: () => T): T {
const prevContext = evalContext
evalContext = undefined
try {
return fn()
} finally {
evalContext = prevContext
}
} | /**
* Run a callback function that can access signal values without
* subscribing to the signal updates.
*
* @param fn The callback function.
* @returns The value returned by the callback.
*/ | https://github.com/starfederation/datastar/blob/fa679aa40c46bdd08d3e5230c4d4465ea795ba45/library/src/vendored/preact-core.ts#L121-L129 | fa679aa40c46bdd08d3e5230c4d4465ea795ba45 |
datastar | github_2023 | starfederation | typescript | Signal | function Signal(this: Signal, value?: unknown) {
this._value = value
this._version = 0
this._node = undefined
this._targets = undefined
} | /** @internal */ | https://github.com/starfederation/datastar/blob/fa679aa40c46bdd08d3e5230c4d4465ea795ba45/library/src/vendored/preact-core.ts#L287-L292 | fa679aa40c46bdd08d3e5230c4d4465ea795ba45 |
datastar | github_2023 | starfederation | typescript | computed | function computed<T>(fn: () => T): ReadonlySignal<T> {
return new Computed(fn)
} | /**
* Create a new signal that is computed based on the values of other signals.
*
* The returned computed signal is read-only, and its value is automatically
* updated when any signals accessed from within the callback function change.
*
* @param fn The effect callback.
* @returns A new read-only signal.
*/ | https://github.com/starfederation/datastar/blob/fa679aa40c46bdd08d3e5230c4d4465ea795ba45/library/src/vendored/preact-core.ts#L694-L696 | fa679aa40c46bdd08d3e5230c4d4465ea795ba45 |
datastar | github_2023 | starfederation | typescript | Effect | function Effect(this: Effect, fn: EffectFn) {
this._fn = fn
this._cleanup = undefined
this._sources = undefined
this._nextBatchedEffect = undefined
this._flags = TRACKING
} | // biome-ignore lint/suspicious/noRedeclare: <explanation> | https://github.com/starfederation/datastar/blob/fa679aa40c46bdd08d3e5230c4d4465ea795ba45/library/src/vendored/preact-core.ts#L768-L774 | fa679aa40c46bdd08d3e5230c4d4465ea795ba45 |
datastar | github_2023 | starfederation | typescript | effect | function effect(fn: EffectFn): () => void {
const effect = new Effect(fn)
try {
effect._callback()
} catch (error) {
effect._dispose()
// Throw the error, since it is already a Datastar error.
throw error
}
// Return a bound function instead of a wrapper like `() => effect._dispose()`,
// be... | /**
* Create an effect to run arbitrary code in response to signal changes.
*
* An effect tracks which signals are accessed within the given callback
* function `fn`, and re-runs the callback when those signals change.
*
* The callback may return a cleanup function. The cleanup function gets
* run once, either w... | https://github.com/starfederation/datastar/blob/fa679aa40c46bdd08d3e5230c4d4465ea795ba45/library/src/vendored/preact-core.ts#L835-L847 | fa679aa40c46bdd08d3e5230c4d4465ea795ba45 |
datastar | github_2023 | starfederation | typescript | ServerSentEventGenerator.stream | static async stream(
req: IncomingMessage,
res: ServerResponse,
onStart: (stream: ServerSentEventGenerator) => Promise<void> | void,
options?: Partial<{
onError: (
stream: ServerSentEventGenerator,
error: unknown,
) => Promise<void> | void;
}>,
): Promise<void> {
co... | /**
* Initializes the server-sent event generator and executes the streamFunc function.
*
* @param req - The NodeJS request object.
* @param res - The NodeJS response object.
* @param onStart - A function that will be passed the initialized ServerSentEventGenerator class as it's first parameter.
*/ | https://github.com/starfederation/datastar/blob/fa679aa40c46bdd08d3e5230c4d4465ea795ba45/sdk/typescript/src/node/serverSentEventGenerator.ts#L40-L63 | fa679aa40c46bdd08d3e5230c4d4465ea795ba45 |
datastar | github_2023 | starfederation | typescript | ServerSentEventGenerator.readSignals | static async readSignals(request: IncomingMessage): Promise<
| { success: true; signals: Record<string, Jsonifiable> }
| { success: false; error: string }
> {
if (request.method === "GET") {
const url = new URL(
`http://${process.env.HOST ?? "localhost"}${request.url}`,
);
const ... | /**
* Reads client sent signals based on HTTP methods
*
* @params request - The NodeJS Request object.
*
* @returns An object containing a success boolean and either the client's signals or an error message.
*/ | https://github.com/starfederation/datastar/blob/fa679aa40c46bdd08d3e5230c4d4465ea795ba45/sdk/typescript/src/node/serverSentEventGenerator.ts#L86-L135 | fa679aa40c46bdd08d3e5230c4d4465ea795ba45 |
datastar | github_2023 | starfederation | typescript | ServerSentEventGenerator.close | public close() {
this.controller.close();
} | /**
* Closes the ReadableStream
*/ | https://github.com/starfederation/datastar/blob/fa679aa40c46bdd08d3e5230c4d4465ea795ba45/sdk/typescript/src/web/serverSentEventGenerator.ts#L27-L29 | fa679aa40c46bdd08d3e5230c4d4465ea795ba45 |
datastar | github_2023 | starfederation | typescript | ServerSentEventGenerator.stream | static stream(
onStart: (stream: ServerSentEventGenerator) => Promise<void> | void,
options?: Partial<{
onError: (
stream: ServerSentEventGenerator,
error: unknown,
) => Promise<void> | void;
onAbort: (reason: string) => Promise<void> | void;
init: ResponseInit;
}>,
... | /**
* Initializes the server-sent event generator and executes the streamFunc function.
*
* @param onStart - A function that will be passed the initialized ServerSentEventGenerator class as it's first parameter.
* @param options? - An object that can contain options for the Response constructor as well as o... | https://github.com/starfederation/datastar/blob/fa679aa40c46bdd08d3e5230c4d4465ea795ba45/sdk/typescript/src/web/serverSentEventGenerator.ts#L42-L93 | fa679aa40c46bdd08d3e5230c4d4465ea795ba45 |
datastar | github_2023 | starfederation | typescript | ServerSentEventGenerator.readSignals | static async readSignals(request: Request): Promise<
| { success: true; signals: Record<string, Jsonifiable> }
| { success: false; error: string }
> {
try {
if (request.method === "GET") {
const url = new URL(request.url);
const params = url.searchParams;
if (params.has("data... | /**
* Reads client sent signals based on HTTP methods
*
* @params request - The HTTP Request object.
*
* @returns An object containing a success boolean and either the client's signals or an error message.
*/ | https://github.com/starfederation/datastar/blob/fa679aa40c46bdd08d3e5230c4d4465ea795ba45/sdk/typescript/src/web/serverSentEventGenerator.ts#L116-L147 | fa679aa40c46bdd08d3e5230c4d4465ea795ba45 |
vsc-cec-ide | github_2023 | qxchuckle | typescript | getSensitiveWordsFilePath | function getSensitiveWordsFilePath(context: vscode.ExtensionContext): string {
let sensitiveWordsFilePath = path.join(context.extensionPath, 'resource', 'text', 'SensitiveWordsEncryption.txt');
const customSensitiveWordsPath = path.join(context.extensionPath, 'resource', 'text', 'CustomSensitiveWords.txt');
try {... | // 获取敏感词文件路径 | https://github.com/qxchuckle/vsc-cec-ide/blob/4e23c5404256a7aaca53eb7c6125a5f12feea6a6/src/sensitiveWords/CheckForSensitiveWords.ts#L33-L44 | 4e23c5404256a7aaca53eb7c6125a5f12feea6a6 |
vsc-cec-ide | github_2023 | qxchuckle | typescript | activateDocumentChangeListener | function activateDocumentChangeListener(document: vscode.TextDocument, mint: ref<Mint>) {
if (!documentListeners[document.fileName]) {
const listener = vscode.workspace.onDidChangeTextDocument(event => {
const editor = vscode.window.activeTextEditor;
if (editor && editor.document === document && mint)... | // 激活文档更改监听器 | https://github.com/qxchuckle/vsc-cec-ide/blob/4e23c5404256a7aaca53eb7c6125a5f12feea6a6/src/sensitiveWords/DetectSensitiveWords.ts#L69-L79 | 4e23c5404256a7aaca53eb7c6125a5f12feea6a6 |
vsc-cec-ide | github_2023 | qxchuckle | typescript | stopSensitiveWordDetection | function stopSensitiveWordDetection(document: vscode.TextDocument) {
cleanUpDocument(document, () => {
statusBar.setStatusbar("default");
diagnosticCollection.delete(document.uri);
vscode.window.showInformationMessage(`已停止检测敏感词。`);
});
} | // 停止敏感词检测、清除标记 | https://github.com/qxchuckle/vsc-cec-ide/blob/4e23c5404256a7aaca53eb7c6125a5f12feea6a6/src/sensitiveWords/DetectSensitiveWords.ts#L91-L97 | 4e23c5404256a7aaca53eb7c6125a5f12feea6a6 |
vsc-cec-ide | github_2023 | qxchuckle | typescript | cleanUpDocument | function cleanUpDocument(document: vscode.TextDocument, callback?: () => void) {
if (fileStates[document.fileName]) {
delete fileStates[document.fileName];
if (documentListeners[document.fileName]) {
documentListeners[document.fileName].dispose();
delete documentListeners[document.fileName];
}... | // 进行文档清理操作 | https://github.com/qxchuckle/vsc-cec-ide/blob/4e23c5404256a7aaca53eb7c6125a5f12feea6a6/src/sensitiveWords/DetectSensitiveWords.ts#L100-L111 | 4e23c5404256a7aaca53eb7c6125a5f12feea6a6 |
vsc-cec-ide | github_2023 | qxchuckle | typescript | detectionMarkDiagnosis | function detectionMarkDiagnosis(document: vscode.TextDocument, mint: ref<Mint>) {
const text = document.getText();
let textWithoutPunctuation = text.replace(/[^\u4e00-\u9fa5]*/g, ''); // 只保留中文,用于检测 你#1a好 情况
textWithoutPunctuation += "#" + text.replace(/[^a-zA-Z]*/g, ''); // 只保留英文,用于检测 a#你1b 情况
textWithoutPunctu... | // 检测敏感词、标记诊断 | https://github.com/qxchuckle/vsc-cec-ide/blob/4e23c5404256a7aaca53eb7c6125a5f12feea6a6/src/sensitiveWords/DetectSensitiveWords.ts#L114-L171 | 4e23c5404256a7aaca53eb7c6125a5f12feea6a6 |
vsc-cec-ide | github_2023 | qxchuckle | typescript | SensitivityStatusBar.constructor | constructor(private fileStates: { [key: string]: boolean }) {
this.statusBar = vscode.window.createStatusBarItem(vscode.StatusBarAlignment.Right, 100);
this.setStatusbar("default");
this.statusBar.show();
vscode.window.onDidChangeActiveTextEditor(editor => {
if (!editor) {
return;
}
... | // 记录文件敏感词数量 | https://github.com/qxchuckle/vsc-cec-ide/blob/4e23c5404256a7aaca53eb7c6125a5f12feea6a6/src/sensitiveWords/SensitivityStatusBar.ts#L7-L21 | 4e23c5404256a7aaca53eb7c6125a5f12feea6a6 |
yf-boot | github_2023 | yf-team | typescript | setupAll | const setupAll = async () => {
const app = createApp(App)
await setupI18n(app)
setupStore(app)
setupGlobCom(app)
setupElementPlus(app)
setupRouter(app)
setupPermission(app)
app.mount('#app')
} | // 创建实例 | https://github.com/yf-team/yf-boot/blob/41d247cac588f96a59a50adbe108846605c3d5b2/yf-boot-vue/src/main.ts#L38-L54 | 41d247cac588f96a59a50adbe108846605c3d5b2 |
yf-boot | github_2023 | yf-team | typescript | filterSearchSchema | const filterSearchSchema = (crudSchema: CrudSchema[]): FormSchema[] => {
const searchSchema: FormSchema[] = []
const length = crudSchema.length
for (let i = 0; i < length; i++) {
const schemaItem = crudSchema[i]
// 判断是否隐藏
if (!schemaItem?.search?.hidden) {
const searchSchemaItem = {
com... | // 过滤 Search 结构 | https://github.com/yf-team/yf-boot/blob/41d247cac588f96a59a50adbe108846605c3d5b2/yf-boot-vue/src/hooks/web/useCrudSchemas.ts#L75-L98 | 41d247cac588f96a59a50adbe108846605c3d5b2 |
yf-boot | github_2023 | yf-team | typescript | filterTableSchema | const filterTableSchema = (crudSchema: CrudSchema[]): TableColumn[] => {
const tableColumns = treeMap<CrudSchema>(crudSchema, {
conversion: (schema: CrudSchema) => {
if (!schema?.table?.hidden) {
return {
...schema.table,
...schema
}
}
}
})
// 第一次过滤会有 undef... | // 过滤 table 结构 | https://github.com/yf-team/yf-boot/blob/41d247cac588f96a59a50adbe108846605c3d5b2/yf-boot-vue/src/hooks/web/useCrudSchemas.ts#L101-L120 | 41d247cac588f96a59a50adbe108846605c3d5b2 |
yf-boot | github_2023 | yf-team | typescript | filterFormSchema | const filterFormSchema = (crudSchema: CrudSchema[]): FormSchema[] => {
const formSchema: FormSchema[] = []
const length = crudSchema.length
for (let i = 0; i < length; i++) {
const formItem = crudSchema[i]
// 判断是否隐藏
if (!formItem?.form?.hidden) {
const formSchemaItem = {
component: form... | // 过滤 form 结构 | https://github.com/yf-team/yf-boot/blob/41d247cac588f96a59a50adbe108846605c3d5b2/yf-boot-vue/src/hooks/web/useCrudSchemas.ts#L123-L146 | 41d247cac588f96a59a50adbe108846605c3d5b2 |
yf-boot | github_2023 | yf-team | typescript | filterDescriptionsSchema | const filterDescriptionsSchema = (crudSchema: CrudSchema[]): DescriptionsSchema[] => {
const descriptionsSchema: FormSchema[] = []
eachTree(crudSchema, (schemaItem: CrudSchema) => {
// 判断是否隐藏
if (!schemaItem?.detail?.hidden) {
const descriptionsSchemaItem = {
...schemaItem.detail,
fie... | // 过滤 descriptions 结构 | https://github.com/yf-team/yf-boot/blob/41d247cac588f96a59a50adbe108846605c3d5b2/yf-boot-vue/src/hooks/web/useCrudSchemas.ts#L149-L169 | 41d247cac588f96a59a50adbe108846605c3d5b2 |
yf-boot | github_2023 | yf-team | typescript | getPrefixCls | const getPrefixCls = (scope: string) => {
return `${lessVariables.namespace}-${scope}`
} | /**
* @param scope 类名
* @returns 返回空间名-类名
*/ | https://github.com/yf-team/yf-boot/blob/41d247cac588f96a59a50adbe108846605c3d5b2/yf-boot-vue/src/hooks/web/useDesign.ts#L10-L12 | 41d247cac588f96a59a50adbe108846605c3d5b2 |
yf-boot | github_2023 | yf-team | typescript | register | const register = (ref: typeof Form & FormExpose, elRef: ComponentRef<typeof ElForm>) => {
formRef.value = ref
elFormRef.value = elRef
} | /**
* @param ref Form实例
* @param elRef ElForm实例
*/ | https://github.com/yf-team/yf-boot/blob/41d247cac588f96a59a50adbe108846605c3d5b2/yf-boot-vue/src/hooks/web/useForm.ts#L17-L20 | 41d247cac588f96a59a50adbe108846605c3d5b2 |
yf-boot | github_2023 | yf-team | typescript | changeLocale | const changeLocale = async (locale: LocaleType) => {
const globalI18n = i18n.global
const langModule = await import(`../../locales/${locale}.ts`)
globalI18n.setLocaleMessage(locale, langModule.default)
setI18nLanguage(locale)
} | // Switching the language will change the locale of useI18n | https://github.com/yf-team/yf-boot/blob/41d247cac588f96a59a50adbe108846605c3d5b2/yf-boot-vue/src/hooks/web/useLocale.ts#L22-L30 | 41d247cac588f96a59a50adbe108846605c3d5b2 |
yf-boot | github_2023 | yf-team | typescript | register | const register = (ref: SearchExpose) => {
searchRef.value = ref
} | /**
* @param ref Search实例
* @param elRef ElForm实例
*/ | https://github.com/yf-team/yf-boot/blob/41d247cac588f96a59a50adbe108846605c3d5b2/yf-boot-vue/src/hooks/web/useSearch.ts#L13-L15 | 41d247cac588f96a59a50adbe108846605c3d5b2 |
yf-boot | github_2023 | yf-team | typescript | getValueType | const getValueType = (value: any) => {
const type = Object.prototype.toString.call(value)
return type.slice(8, -1)
} | // 获取传入的值的类型 | https://github.com/yf-team/yf-boot/blob/41d247cac588f96a59a50adbe108846605c3d5b2/yf-boot-vue/src/hooks/web/useStorage.ts#L2-L5 | 41d247cac588f96a59a50adbe108846605c3d5b2 |
yf-boot | github_2023 | yf-team | typescript | addLight | const addLight = (color: string, amount: number) => {
const cc = parseInt(color, 16) + amount
const c = cc > 255 ? 255 : cc
return c.toString(16).length > 1 ? c.toString(16) : `0${c.toString(16)}`
} | /* Suma el porcentaje indicado a un color (RR, GG o BB) hexadecimal para aclararlo */ | https://github.com/yf-team/yf-boot/blob/41d247cac588f96a59a50adbe108846605c3d5b2/yf-boot-vue/src/utils/color.ts#L100-L104 | 41d247cac588f96a59a50adbe108846605c3d5b2 |
yf-boot | github_2023 | yf-team | typescript | luminanace | const luminanace = (r: number, g: number, b: number) => {
const a = [r, g, b].map((v) => {
v /= 255
return v <= 0.03928 ? v / 12.92 : Math.pow((v + 0.055) / 1.055, 2.4)
})
return a[0] * 0.2126 + a[1] * 0.7152 + a[2] * 0.0722
} | /**
* Calculates luminance of an rgb color
* @param {number} r red
* @param {number} g green
* @param {number} b blue
*/ | https://github.com/yf-team/yf-boot/blob/41d247cac588f96a59a50adbe108846605c3d5b2/yf-boot-vue/src/utils/color.ts#L112-L118 | 41d247cac588f96a59a50adbe108846605c3d5b2 |
yf-boot | github_2023 | yf-team | typescript | contrast | const contrast = (rgb1: string[], rgb2: number[]) => {
return (
(luminanace(~~rgb1[0], ~~rgb1[1], ~~rgb1[2]) + 0.05) /
(luminanace(rgb2[0], rgb2[1], rgb2[2]) + 0.05)
)
} | /**
* Calculates contrast between two rgb colors
* @param {string} rgb1 rgb color 1
* @param {string} rgb2 rgb color 2
*/ | https://github.com/yf-team/yf-boot/blob/41d247cac588f96a59a50adbe108846605c3d5b2/yf-boot-vue/src/utils/color.ts#L125-L130 | 41d247cac588f96a59a50adbe108846605c3d5b2 |
yf-boot | github_2023 | yf-team | typescript | subtractLight | const subtractLight = (color: string, amount: number) => {
const cc = parseInt(color, 16) - amount
const c = cc < 0 ? 0 : cc
return c.toString(16).length > 1 ? c.toString(16) : `0${c.toString(16)}`
} | /**
* Subtracts the indicated percentage to the R, G or B of a HEX color
* @param {string} color The color to change
* @param {number} amount The amount to change the color by
* @returns {string} The processed part of the color
*/ | https://github.com/yf-team/yf-boot/blob/41d247cac588f96a59a50adbe108846605c3d5b2/yf-boot-vue/src/utils/color.ts#L149-L153 | 41d247cac588f96a59a50adbe108846605c3d5b2 |
yf-boot | github_2023 | yf-team | typescript | isMultipleRoute | const isMultipleRoute = (route: AppRouteRecordRaw) => {
if (!route || !Reflect.has(route, 'children') || !route.children?.length) {
return false
}
const children = route.children
let flag = false
for (let index = 0; index < children.length; index++) {
const child = children[index]
if (child.chil... | // 层级是否大于2 | https://github.com/yf-team/yf-boot/blob/41d247cac588f96a59a50adbe108846605c3d5b2/yf-boot-vue/src/utils/routerHelper.ts#L91-L107 | 41d247cac588f96a59a50adbe108846605c3d5b2 |
yf-boot | github_2023 | yf-team | typescript | promoteRouteLevel | const promoteRouteLevel = (route: AppRouteRecordRaw) => {
let router: Router | null = createRouter({
routes: [route as RouteRecordRaw],
history: createWebHashHistory()
})
const routes = router.getRoutes()
addToChildren(routes, route.children || [], route)
router = null
route.children = route.child... | // 生成二级路由 | https://github.com/yf-team/yf-boot/blob/41d247cac588f96a59a50adbe108846605c3d5b2/yf-boot-vue/src/utils/routerHelper.ts#L110-L121 | 41d247cac588f96a59a50adbe108846605c3d5b2 |
yf-boot | github_2023 | yf-team | typescript | addToChildren | const addToChildren = (
routes: RouteRecordNormalized[],
children: AppRouteRecordRaw[],
routeModule: AppRouteRecordRaw
) => {
for (let index = 0; index < children.length; index++) {
const child = children[index]
const route = routes.find((item) => item.name === child.name)
if (!route) {
contin... | // 添加所有子菜单 | https://github.com/yf-team/yf-boot/blob/41d247cac588f96a59a50adbe108846605c3d5b2/yf-boot-vue/src/utils/routerHelper.ts#L124-L143 | 41d247cac588f96a59a50adbe108846605c3d5b2 |
use-shader-fx | github_2023 | FunTechInc | typescript | getHash | function getHash(input: number) {
let n = Math.sin(input * 12.9898) * 43758.5453;
return n - Math.floor(n);
} | /** Returns a unique hash specific to the beat */ | https://github.com/FunTechInc/use-shader-fx/blob/338e63427310a6b13947f68c5863e4cf4bbb62f1/packages/use-shader-fx/src/misc/useBeat.ts#L6-L9 | 338e63427310a6b13947f68c5863e4cf4bbb62f1 |
whisper_android | github_2023 | vilassn | typescript | Monster.testarrayoftables | testarrayoftables(index: number, obj?:Monster):Monster|null {
const offset = this.bb!.__offset(this.bb_pos, 26);
return offset ? (obj || new Monster()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null;
} | /**
* an example documentation comment: this will end up in the generated code
* multiline too
*/ | https://github.com/vilassn/whisper_android/blob/08b766af195510e1ac6ede69cb152d8ca9ebb37e/whisper_native/app/src/main/cpp/tf-lite-api/include/flatbuffers/tests/my-game/example/monster.ts#L156-L159 | 08b766af195510e1ac6ede69cb152d8ca9ebb37e |
whisper_android | github_2023 | vilassn | typescript | Type.baseSize | baseSize():number {
const offset = this.bb!.__offset(this.bb_pos, 12);
return offset ? this.bb!.readUint32(this.bb_pos + offset) : 4;
} | /**
* The size (octets) of the `base_type` field.
*/ | https://github.com/vilassn/whisper_android/blob/08b766af195510e1ac6ede69cb152d8ca9ebb37e/whisper_native/app/src/main/cpp/tf-lite-api/include/flatbuffers/tests/ts/reflection_generated.ts#L123-L126 | 08b766af195510e1ac6ede69cb152d8ca9ebb37e |
whisper_android | github_2023 | vilassn | typescript | Type.elementSize | elementSize():number {
const offset = this.bb!.__offset(this.bb_pos, 14);
return offset ? this.bb!.readUint32(this.bb_pos + offset) : 0;
} | /**
* The size (octets) of the `element` field, if present.
*/ | https://github.com/vilassn/whisper_android/blob/08b766af195510e1ac6ede69cb152d8ca9ebb37e/whisper_native/app/src/main/cpp/tf-lite-api/include/flatbuffers/tests/ts/reflection_generated.ts#L142-L145 | 08b766af195510e1ac6ede69cb152d8ca9ebb37e |
whisper_android | github_2023 | vilassn | typescript | Field.padding | padding():number {
const offset = this.bb!.__offset(this.bb_pos, 28);
return offset ? this.bb!.readUint16(this.bb_pos + offset) : 0;
} | /**
* Number of padding octets to always add after this field. Structs only.
*/ | https://github.com/vilassn/whisper_android/blob/08b766af195510e1ac6ede69cb152d8ca9ebb37e/whisper_native/app/src/main/cpp/tf-lite-api/include/flatbuffers/tests/ts/reflection_generated.ts#L927-L930 | 08b766af195510e1ac6ede69cb152d8ca9ebb37e |
whisper_android | github_2023 | vilassn | typescript | Schema.fbsFiles | fbsFiles(index: number, obj?:SchemaFile):SchemaFile|null {
const offset = this.bb!.__offset(this.bb_pos, 18);
return offset ? (obj || new SchemaFile()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null;
} | /**
* All the files used in this compilation. Files are relative to where
* flatc was invoked.
*/ | https://github.com/vilassn/whisper_android/blob/08b766af195510e1ac6ede69cb152d8ca9ebb37e/whisper_native/app/src/main/cpp/tf-lite-api/include/flatbuffers/tests/ts/reflection_generated.ts#L1956-L1959 | 08b766af195510e1ac6ede69cb152d8ca9ebb37e |
whisper_android | github_2023 | vilassn | typescript | Monster.testarrayoftables | testarrayoftables(index: number, obj?:Monster):Monster|null {
const offset = this.bb!.__offset(this.bb_pos, 26);
return offset ? (obj || new Monster()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null;
} | /**
* an example documentation comment: this will end up in the generated code
* multiline too
*/ | https://github.com/vilassn/whisper_android/blob/08b766af195510e1ac6ede69cb152d8ca9ebb37e/whisper_native/app/src/main/cpp/tf-lite-api/include/flatbuffers/tests/ts/my-game/example/monster.ts#L156-L159 | 08b766af195510e1ac6ede69cb152d8ca9ebb37e |
whisper_android | github_2023 | vilassn | typescript | Field.padding | padding():number {
const offset = this.bb!.__offset(this.bb_pos, 28);
return offset ? this.bb!.readUint16(this.bb_pos + offset) : 0;
} | /**
* Number of padding octets to always add after this field. Structs only.
*/ | https://github.com/vilassn/whisper_android/blob/08b766af195510e1ac6ede69cb152d8ca9ebb37e/whisper_native/app/src/main/cpp/tf-lite-api/include/flatbuffers/tests/ts/reflection/field.ts#L192-L195 | 08b766af195510e1ac6ede69cb152d8ca9ebb37e |
whisper_android | github_2023 | vilassn | typescript | Schema.fbsFiles | fbsFiles(index: number, obj?:SchemaFile):SchemaFile|null {
const offset = this.bb!.__offset(this.bb_pos, 18);
return offset ? (obj || new SchemaFile()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null;
} | /**
* All the files used in this compilation. Files are relative to where
* flatc was invoked.
*/ | https://github.com/vilassn/whisper_android/blob/08b766af195510e1ac6ede69cb152d8ca9ebb37e/whisper_native/app/src/main/cpp/tf-lite-api/include/flatbuffers/tests/ts/reflection/schema.ts#L102-L105 | 08b766af195510e1ac6ede69cb152d8ca9ebb37e |
whisper_android | github_2023 | vilassn | typescript | Type.baseSize | baseSize():number {
const offset = this.bb!.__offset(this.bb_pos, 12);
return offset ? this.bb!.readUint32(this.bb_pos + offset) : 4;
} | /**
* The size (octets) of the `base_type` field.
*/ | https://github.com/vilassn/whisper_android/blob/08b766af195510e1ac6ede69cb152d8ca9ebb37e/whisper_native/app/src/main/cpp/tf-lite-api/include/flatbuffers/tests/ts/reflection/type.ts#L93-L96 | 08b766af195510e1ac6ede69cb152d8ca9ebb37e |
whisper_android | github_2023 | vilassn | typescript | Type.elementSize | elementSize():number {
const offset = this.bb!.__offset(this.bb_pos, 14);
return offset ? this.bb!.readUint32(this.bb_pos + offset) : 0;
} | /**
* The size (octets) of the `element` field, if present.
*/ | https://github.com/vilassn/whisper_android/blob/08b766af195510e1ac6ede69cb152d8ca9ebb37e/whisper_native/app/src/main/cpp/tf-lite-api/include/flatbuffers/tests/ts/reflection/type.ts#L112-L115 | 08b766af195510e1ac6ede69cb152d8ca9ebb37e |
whisper_android | github_2023 | vilassn | typescript | MyGame_Example_Monster.testarrayoftables | testarrayoftables(index: number, obj?:MyGame_Example_Monster):MyGame_Example_Monster|null {
const offset = this.bb!.__offset(this.bb_pos, 26);
return offset ? (obj || new MyGame_Example_Monster()).__init(this.bb!.__indirect(this.bb!.__vector(this.bb_pos + offset) + index * 4), this.bb!) : null;
} | /**
* an example documentation comment: this will end up in the generated code
* multiline too
*/ | https://github.com/vilassn/whisper_android/blob/08b766af195510e1ac6ede69cb152d8ca9ebb37e/whisper_native/app/src/main/cpp/tf-lite-api/include/flatbuffers/tests/ts/ts-flat-files/monster_test_generated.ts#L823-L826 | 08b766af195510e1ac6ede69cb152d8ca9ebb37e |
whisper_android | github_2023 | vilassn | typescript | Builder.constructor | constructor(opt_initial_size?: number) {
let initial_size: number;
if (!opt_initial_size) {
initial_size = 1024;
} else {
initial_size = opt_initial_size;
}
/**
* @type {ByteBuffer}
* @private
*/
this.bb = ByteBuffer.allocate(initial_size);
... | /**
* Create a FlatBufferBuilder.
*/ | https://github.com/vilassn/whisper_android/blob/08b766af195510e1ac6ede69cb152d8ca9ebb37e/whisper_native/app/src/main/cpp/tf-lite-api/include/flatbuffers/ts/builder.ts#L32-L47 | 08b766af195510e1ac6ede69cb152d8ca9ebb37e |
whisper_android | github_2023 | vilassn | typescript | Builder.forceDefaults | forceDefaults(forceDefaults: boolean): void {
this.force_defaults = forceDefaults;
} | /**
* In order to save space, fields that are set to their default value
* don't get serialized into the buffer. Forcing defaults provides a
* way to manually disable this optimization.
*
* @param forceDefaults true always serializes default values
*/ | https://github.com/vilassn/whisper_android/blob/08b766af195510e1ac6ede69cb152d8ca9ebb37e/whisper_native/app/src/main/cpp/tf-lite-api/include/flatbuffers/ts/builder.ts#L71-L73 | 08b766af195510e1ac6ede69cb152d8ca9ebb37e |
whisper_android | github_2023 | vilassn | typescript | Builder.dataBuffer | dataBuffer(): ByteBuffer {
return this.bb;
} | /**
* Get the ByteBuffer representing the FlatBuffer. Only call this after you've
* called finish(). The actual data starts at the ByteBuffer's current position,
* not necessarily at 0.
*/ | https://github.com/vilassn/whisper_android/blob/08b766af195510e1ac6ede69cb152d8ca9ebb37e/whisper_native/app/src/main/cpp/tf-lite-api/include/flatbuffers/ts/builder.ts#L80-L82 | 08b766af195510e1ac6ede69cb152d8ca9ebb37e |
whisper_android | github_2023 | vilassn | typescript | Builder.asUint8Array | asUint8Array(): Uint8Array {
return this.bb.bytes().subarray(this.bb.position(), this.bb.position() + this.offset());
} | /**
* Get the bytes representing the FlatBuffer. Only call this after you've
* called finish().
*/ | https://github.com/vilassn/whisper_android/blob/08b766af195510e1ac6ede69cb152d8ca9ebb37e/whisper_native/app/src/main/cpp/tf-lite-api/include/flatbuffers/ts/builder.ts#L88-L90 | 08b766af195510e1ac6ede69cb152d8ca9ebb37e |
whisper_android | github_2023 | vilassn | typescript | Builder.prep | prep(size: number, additional_bytes: number): void {
// Track the biggest thing we've ever aligned to.
if (size > this.minalign) {
this.minalign = size;
}
// Find the amount of alignment needed such that `size` is properly
// aligned after `additional_bytes`
const align_si... | /**
* Prepare to write an element of `size` after `additional_bytes` have been
* written, e.g. if you write a string, you need to align such the int length
* field is aligned to 4 bytes, and the string data follows it directly. If all
* you need to do is alignment, `additional_bytes` will be 0.
... | https://github.com/vilassn/whisper_android/blob/08b766af195510e1ac6ede69cb152d8ca9ebb37e/whisper_native/app/src/main/cpp/tf-lite-api/include/flatbuffers/ts/builder.ts#L101-L119 | 08b766af195510e1ac6ede69cb152d8ca9ebb37e |
whisper_android | github_2023 | vilassn | typescript | Builder.addInt8 | addInt8(value: number): void {
this.prep(1, 0);
this.writeInt8(value);
} | /**
* Add an `int8` to the buffer, properly aligned, and grows the buffer (if necessary).
* @param value The `int8` to add the buffer.
*/ | https://github.com/vilassn/whisper_android/blob/08b766af195510e1ac6ede69cb152d8ca9ebb37e/whisper_native/app/src/main/cpp/tf-lite-api/include/flatbuffers/ts/builder.ts#L155-L158 | 08b766af195510e1ac6ede69cb152d8ca9ebb37e |
whisper_android | github_2023 | vilassn | typescript | Builder.addInt16 | addInt16(value: number): void {
this.prep(2, 0);
this.writeInt16(value);
} | /**
* Add an `int16` to the buffer, properly aligned, and grows the buffer (if necessary).
* @param value The `int16` to add the buffer.
*/ | https://github.com/vilassn/whisper_android/blob/08b766af195510e1ac6ede69cb152d8ca9ebb37e/whisper_native/app/src/main/cpp/tf-lite-api/include/flatbuffers/ts/builder.ts#L164-L167 | 08b766af195510e1ac6ede69cb152d8ca9ebb37e |
whisper_android | github_2023 | vilassn | typescript | Builder.addInt32 | addInt32(value: number): void {
this.prep(4, 0);
this.writeInt32(value);
} | /**
* Add an `int32` to the buffer, properly aligned, and grows the buffer (if necessary).
* @param value The `int32` to add the buffer.
*/ | https://github.com/vilassn/whisper_android/blob/08b766af195510e1ac6ede69cb152d8ca9ebb37e/whisper_native/app/src/main/cpp/tf-lite-api/include/flatbuffers/ts/builder.ts#L173-L176 | 08b766af195510e1ac6ede69cb152d8ca9ebb37e |
whisper_android | github_2023 | vilassn | typescript | Builder.addInt64 | addInt64(value: bigint): void {
this.prep(8, 0);
this.writeInt64(value);
} | /**
* Add an `int64` to the buffer, properly aligned, and grows the buffer (if necessary).
* @param value The `int64` to add the buffer.
*/ | https://github.com/vilassn/whisper_android/blob/08b766af195510e1ac6ede69cb152d8ca9ebb37e/whisper_native/app/src/main/cpp/tf-lite-api/include/flatbuffers/ts/builder.ts#L182-L185 | 08b766af195510e1ac6ede69cb152d8ca9ebb37e |
whisper_android | github_2023 | vilassn | typescript | Builder.addFloat32 | addFloat32(value: number): void {
this.prep(4, 0);
this.writeFloat32(value);
} | /**
* Add a `float32` to the buffer, properly aligned, and grows the buffer (if necessary).
* @param value The `float32` to add the buffer.
*/ | https://github.com/vilassn/whisper_android/blob/08b766af195510e1ac6ede69cb152d8ca9ebb37e/whisper_native/app/src/main/cpp/tf-lite-api/include/flatbuffers/ts/builder.ts#L191-L194 | 08b766af195510e1ac6ede69cb152d8ca9ebb37e |
whisper_android | github_2023 | vilassn | typescript | Builder.addFloat64 | addFloat64(value: number): void {
this.prep(8, 0);
this.writeFloat64(value);
} | /**
* Add a `float64` to the buffer, properly aligned, and grows the buffer (if necessary).
* @param value The `float64` to add the buffer.
*/ | https://github.com/vilassn/whisper_android/blob/08b766af195510e1ac6ede69cb152d8ca9ebb37e/whisper_native/app/src/main/cpp/tf-lite-api/include/flatbuffers/ts/builder.ts#L200-L203 | 08b766af195510e1ac6ede69cb152d8ca9ebb37e |
whisper_android | github_2023 | vilassn | typescript | Builder.addFieldStruct | addFieldStruct(voffset: number, value: Offset, defaultValue: Offset): void {
if (value != defaultValue) {
this.nested(value);
this.slot(voffset);
}
} | /**
* Structs are stored inline, so nothing additional is being added. `d` is always 0.
*/ | https://github.com/vilassn/whisper_android/blob/08b766af195510e1ac6ede69cb152d8ca9ebb37e/whisper_native/app/src/main/cpp/tf-lite-api/include/flatbuffers/ts/builder.ts#L257-L262 | 08b766af195510e1ac6ede69cb152d8ca9ebb37e |
whisper_android | github_2023 | vilassn | typescript | Builder.nested | nested(obj: Offset): void {
if (obj != this.offset()) {
throw new Error('FlatBuffers: struct must be serialized inline.');
}
} | /**
* Structures are always stored inline, they need to be created right
* where they're used. You'll get this assertion failure if you
* created it elsewhere.
*/ | https://github.com/vilassn/whisper_android/blob/08b766af195510e1ac6ede69cb152d8ca9ebb37e/whisper_native/app/src/main/cpp/tf-lite-api/include/flatbuffers/ts/builder.ts#L269-L273 | 08b766af195510e1ac6ede69cb152d8ca9ebb37e |
whisper_android | github_2023 | vilassn | typescript | Builder.notNested | notNested(): void {
if (this.isNested) {
throw new Error('FlatBuffers: object serialization must not be nested.');
}
} | /**
* Should not be creating any other object, string or vector
* while an object is being constructed
*/ | https://github.com/vilassn/whisper_android/blob/08b766af195510e1ac6ede69cb152d8ca9ebb37e/whisper_native/app/src/main/cpp/tf-lite-api/include/flatbuffers/ts/builder.ts#L279-L283 | 08b766af195510e1ac6ede69cb152d8ca9ebb37e |
whisper_android | github_2023 | vilassn | typescript | Builder.slot | slot(voffset: number): void {
if (this.vtable !== null)
this.vtable[voffset] = this.offset();
} | /**
* Set the current vtable at `voffset` to the current location in the buffer.
*/ | https://github.com/vilassn/whisper_android/blob/08b766af195510e1ac6ede69cb152d8ca9ebb37e/whisper_native/app/src/main/cpp/tf-lite-api/include/flatbuffers/ts/builder.ts#L288-L291 | 08b766af195510e1ac6ede69cb152d8ca9ebb37e |
whisper_android | github_2023 | vilassn | typescript | Builder.offset | offset(): Offset {
return this.bb.capacity() - this.space;
} | /**
* @returns Offset relative to the end of the buffer.
*/ | https://github.com/vilassn/whisper_android/blob/08b766af195510e1ac6ede69cb152d8ca9ebb37e/whisper_native/app/src/main/cpp/tf-lite-api/include/flatbuffers/ts/builder.ts#L296-L298 | 08b766af195510e1ac6ede69cb152d8ca9ebb37e |
whisper_android | github_2023 | vilassn | typescript | Builder.growByteBuffer | static growByteBuffer(bb: ByteBuffer): ByteBuffer {
const old_buf_size = bb.capacity();
// Ensure we don't grow beyond what fits in an int.
if (old_buf_size & 0xC0000000) {
throw new Error('FlatBuffers: cannot grow buffer beyond 2 gigabytes.');
}
const new_buf_size = old_buf_... | /**
* Doubles the size of the backing ByteBuffer and copies the old data towards
* the end of the new buffer (since we build the buffer backwards).
*
* @param bb The current buffer with the existing data
* @returns A new byte buffer with the old data copied
* to it. The data is located at ... | https://github.com/vilassn/whisper_android/blob/08b766af195510e1ac6ede69cb152d8ca9ebb37e/whisper_native/app/src/main/cpp/tf-lite-api/include/flatbuffers/ts/builder.ts#L312-L325 | 08b766af195510e1ac6ede69cb152d8ca9ebb37e |
whisper_android | github_2023 | vilassn | typescript | Builder.addOffset | addOffset(offset: Offset): void {
this.prep(SIZEOF_INT, 0); // Ensure alignment is already done.
this.writeInt32(this.offset() - offset + SIZEOF_INT);
} | /**
* Adds on offset, relative to where it will be written.
*
* @param offset The offset to add.
*/ | https://github.com/vilassn/whisper_android/blob/08b766af195510e1ac6ede69cb152d8ca9ebb37e/whisper_native/app/src/main/cpp/tf-lite-api/include/flatbuffers/ts/builder.ts#L332-L335 | 08b766af195510e1ac6ede69cb152d8ca9ebb37e |
whisper_android | github_2023 | vilassn | typescript | Builder.startObject | startObject(numfields: number): void {
this.notNested();
if (this.vtable == null) {
this.vtable = [];
}
this.vtable_in_use = numfields;
for (let i = 0; i < numfields; i++) {
this.vtable[i] = 0; // This will push additional elements as needed
}
this.isNested = tr... | /**
* Start encoding a new object in the buffer. Users will not usually need to
* call this directly. The FlatBuffers compiler will generate helper methods
* that call this method internally.
*/ | https://github.com/vilassn/whisper_android/blob/08b766af195510e1ac6ede69cb152d8ca9ebb37e/whisper_native/app/src/main/cpp/tf-lite-api/include/flatbuffers/ts/builder.ts#L342-L353 | 08b766af195510e1ac6ede69cb152d8ca9ebb37e |
whisper_android | github_2023 | vilassn | typescript | Builder.endObject | endObject(): Offset {
if (this.vtable == null || !this.isNested) {
throw new Error('FlatBuffers: endObject called without startObject');
}
this.addInt32(0);
const vtableloc = this.offset();
// Trim trailing zeroes.
let i = this.vtable_in_use - 1;
// eslint-disable... | /**
* Finish off writing the object that is under construction.
*
* @returns The offset to the object inside `dataBuffer`
*/ | https://github.com/vilassn/whisper_android/blob/08b766af195510e1ac6ede69cb152d8ca9ebb37e/whisper_native/app/src/main/cpp/tf-lite-api/include/flatbuffers/ts/builder.ts#L360-L420 | 08b766af195510e1ac6ede69cb152d8ca9ebb37e |
whisper_android | github_2023 | vilassn | typescript | Builder.finish | finish(root_table: Offset, opt_file_identifier?: string, opt_size_prefix?: boolean): void {
const size_prefix = opt_size_prefix ? SIZE_PREFIX_LENGTH : 0;
if (opt_file_identifier) {
const file_identifier = opt_file_identifier;
this.prep(this.minalign, SIZEOF_INT +
FILE_IDENTIFIER_LE... | /**
* Finalize a buffer, poiting to the given `root_table`.
*/ | https://github.com/vilassn/whisper_android/blob/08b766af195510e1ac6ede69cb152d8ca9ebb37e/whisper_native/app/src/main/cpp/tf-lite-api/include/flatbuffers/ts/builder.ts#L425-L445 | 08b766af195510e1ac6ede69cb152d8ca9ebb37e |
whisper_android | github_2023 | vilassn | typescript | Builder.finishSizePrefixed | finishSizePrefixed(this: Builder, root_table: Offset, opt_file_identifier?: string): void {
this.finish(root_table, opt_file_identifier, true);
} | /**
* Finalize a size prefixed buffer, pointing to the given `root_table`.
*/ | https://github.com/vilassn/whisper_android/blob/08b766af195510e1ac6ede69cb152d8ca9ebb37e/whisper_native/app/src/main/cpp/tf-lite-api/include/flatbuffers/ts/builder.ts#L450-L452 | 08b766af195510e1ac6ede69cb152d8ca9ebb37e |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.