repo_name string | dataset string | owner string | lang string | func_name string | code string | docstring string | url string | sha string |
|---|---|---|---|---|---|---|---|---|
llama-coder | github_2023 | ex3ndr | typescript | normalizeText | function normalizeText(src: string) {
src = src.split('\n').join(' ');
src = src.replace(/\s+/gm, ' ');
return src;
} | // Remove all newlines, double spaces, etc | https://github.com/ex3ndr/llama-coder/blob/d4b65d6737e2c5d4b5797fd77e18e740dd9355df/src/prompts/promptCache.ts#L3-L7 | d4b65d6737e2c5d4b5797fd77e18e740dd9355df |
chrome-power-app | github_2023 | zmzimpl | typescript | findAvailablePortAndStartServer | async function findAvailablePortAndStartServer() {
if (!isDev) {
PORT = await portscanner.findAPortNotInUse(5173, 8000);
server.use(express.static(resolve(__dirname, '../../renderer/dist')));
server.listen(PORT, () => {
console.log(`Server running on http://localhost:${PORT}`);
serverStarted =... | // 仅在生产环境下启动Express服务器 | https://github.com/zmzimpl/chrome-power-app/blob/7c4f40f757838274a54caf1320e59fd04b04f4f3/packages/main/src/mainWindow.ts#L13-L22 | 7c4f40f757838274a54caf1320e59fd04b04f4f3 |
chrome-power-app | github_2023 | zmzimpl | typescript | initializeDatabase | const initializeDatabase = async () => {
const userDataPath = app.getPath('userData');
// 确保目录存在
if (!existsSync(userDataPath)) {
mkdirSync(userDataPath, { recursive: true });
}
try {
// 初始化数据库连接
await db.raw('SELECT 1');
// 运行迁移
await db.migrate.latest({
directory: app.isPa... | // const deleteAll = async () => { | https://github.com/zmzimpl/chrome-power-app/blob/7c4f40f757838274a54caf1320e59fd04b04f4f3/packages/main/src/db/index.ts#L32-L59 | 7c4f40f757838274a54caf1320e59fd04b04f4f3 |
chrome-power-app | github_2023 | zmzimpl | typescript | getDriverPath | const getDriverPath = () => {
const settings = getSettings();
if (settings.useLocalChrome) {
return settings.localChromePath;
} else {
return settings.chromiumBinPath;
}
}; | // async function connectBrowser( | https://github.com/zmzimpl/chrome-power-app/blob/7c4f40f757838274a54caf1320e59fd04b04f4f3/packages/main/src/fingerprint/index.ts#L89-L97 | 7c4f40f757838274a54caf1320e59fd04b04f4f3 |
chrome-power-app | github_2023 | zmzimpl | typescript | getCookie | const getCookie = (windowId: number, domain: CookieDomain) => {
const map = cookieMap.get(windowId);
if (map) {
return map.get(domain);
}
return null;
}; | // const cookieToMap = (windowId: number, cookies: ICookie[]) => { | https://github.com/zmzimpl/chrome-power-app/blob/7c4f40f757838274a54caf1320e59fd04b04f4f3/packages/main/src/puppeteer/helpers.ts#L30-L36 | 7c4f40f757838274a54caf1320e59fd04b04f4f3 |
react-native-live-markdown | github_2023 | Expensify | typescript | getTagPriority | function getTagPriority(tag: string) {
switch (tag) {
case 'blockquote':
return 2;
case 'h1':
return 1;
default:
return 0;
}
} | // getTagPriority returns a priority for a tag, higher priority means the tag should be processed first | https://github.com/Expensify/react-native-live-markdown/blob/958dbd95c635c78ce491105368b5ac45adba228e/src/rangeUtils.ts#L6-L15 | 958dbd95c635c78ce491105368b5ac45adba228e |
react-native-live-markdown | github_2023 | Expensify | typescript | updateImageTreeNode | function updateImageTreeNode(targetNode: TreeNode, newElement: HTMLMarkdownElement, imageMarginTop = 0) {
const paddingBottom = `${parseStringWithUnitToNumber(newElement.style.height) + imageMarginTop}px`;
targetNode.element.appendChild(newElement.cloneNode(true));
let currentParent = targetNode.element;
while... | /** Adds already loaded image element from current input content to the tree node */ | https://github.com/Expensify/react-native-live-markdown/blob/958dbd95c635c78ce491105368b5ac45adba228e/src/web/inputElements/inlineImage.ts#L134-L147 | 958dbd95c635c78ce491105368b5ac45adba228e |
react-native-live-markdown | github_2023 | Expensify | typescript | addInlineImagePreview | function addInlineImagePreview(
currentInput: MarkdownTextInputElement,
targetNode: TreeNode,
text: string,
ranges: MarkdownRange[],
markdownStyle: PartialMarkdownStyle,
inlineImagesProps: InlineImagesInputProps,
) {
const {addAuthTokenToImageURLCallback, imagePreviewAuthRequiredURLs} = inlineImagesProps;... | /** The main function that adds inline image preview to the node */ | https://github.com/Expensify/react-native-live-markdown/blob/958dbd95c635c78ce491105368b5ac45adba228e/src/web/inputElements/inlineImage.ts#L150-L195 | 958dbd95c635c78ce491105368b5ac45adba228e |
react-native-live-markdown | github_2023 | Expensify | typescript | createLoadingIndicator | function createLoadingIndicator(url: string, markdownStyle: PartialMarkdownStyle) {
const container = document.createElement('span');
container.contentEditable = 'false';
const spinner = document.createElement('span');
const spinnerStyles = markdownStyle.loadingIndicator;
if (spinnerStyles) {
const spinn... | /** Creates animated loading spinner */ | https://github.com/Expensify/react-native-live-markdown/blob/958dbd95c635c78ce491105368b5ac45adba228e/src/web/inputElements/loadingIndicator.ts#L18-L49 | 958dbd95c635c78ce491105368b5ac45adba228e |
react-native-live-markdown | github_2023 | Expensify | typescript | getAnimationCurrentTimes | function getAnimationCurrentTimes(currentInput: MarkdownTextInputElement): AnimationTimes {
const animationTimes: AnimationTimes = {};
ANIMATED_ELEMENT_TYPES.forEach((type) => {
const elements = currentInput.querySelectorAll(`[data-type="${type}"]`);
animationTimes[type] = Array.from(elements).map((element... | /** Gets the current times of all animated elements inside the input */ | https://github.com/Expensify/react-native-live-markdown/blob/958dbd95c635c78ce491105368b5ac45adba228e/src/web/utils/animationUtils.ts#L25-L40 | 958dbd95c635c78ce491105368b5ac45adba228e |
react-native-live-markdown | github_2023 | Expensify | typescript | updateAnimationsTime | function updateAnimationsTime(currentInput: MarkdownTextInputElement, animationTimes: AnimationTimes) {
ANIMATED_ELEMENT_TYPES.forEach((type) => {
const elements = currentInput.querySelectorAll(`[data-type="${type}"]`);
if (!KEYFRAMES[type]) {
return;
}
elements.forEach((element, index) => {
... | /** Updates the current times of all animated elements inside the input, to preserve their state between input rerenders */ | https://github.com/Expensify/react-native-live-markdown/blob/958dbd95c635c78ce491105368b5ac45adba228e/src/web/utils/animationUtils.ts#L43-L57 | 958dbd95c635c78ce491105368b5ac45adba228e |
react-native-live-markdown | github_2023 | Expensify | typescript | isEventComposing | function isEventComposing(nativeEvent: globalThis.KeyboardEvent | MarkdownNativeEvent) {
return nativeEvent.isComposing || nativeEvent.keyCode === 229;
} | // If an Input Method Editor is processing key input, the 'keyCode' is 229. | https://github.com/Expensify/react-native-live-markdown/blob/958dbd95c635c78ce491105368b5ac45adba228e/src/web/utils/inputUtils.ts#L8-L10 | 958dbd95c635c78ce491105368b5ac45adba228e |
react-native-live-markdown | github_2023 | Expensify | typescript | parseInnerHTMLToText | function parseInnerHTMLToText(target: MarkdownTextInputElement, cursorPosition: number, inputType?: string): string {
// Returns the parent of a given node that is higher in the hierarchy and is of a different type than 'text', 'br' or 'line'
function getTopParentNode(node: ChildNode) {
let currentParentNode = ... | // Parses the HTML structure of a MarkdownTextInputElement to a plain text string. Used for getting the correct value of the input element. | https://github.com/Expensify/react-native-live-markdown/blob/958dbd95c635c78ce491105368b5ac45adba228e/src/web/utils/inputUtils.ts#L40-L111 | 958dbd95c635c78ce491105368b5ac45adba228e |
react-native-live-markdown | github_2023 | Expensify | typescript | getTopParentNode | function getTopParentNode(node: ChildNode) {
let currentParentNode = node.parentNode;
while (currentParentNode && ['text', 'br', 'line'].includes(currentParentNode.parentElement?.getAttribute('data-type') || '')) {
currentParentNode = currentParentNode?.parentNode || null;
}
return currentParentNo... | // Returns the parent of a given node that is higher in the hierarchy and is of a different type than 'text', 'br' or 'line' | https://github.com/Expensify/react-native-live-markdown/blob/958dbd95c635c78ce491105368b5ac45adba228e/src/web/utils/inputUtils.ts#L42-L48 | 958dbd95c635c78ce491105368b5ac45adba228e |
react-native-live-markdown | github_2023 | Expensify | typescript | mergeLinesWithMultilineTags | function mergeLinesWithMultilineTags(lines: Paragraph[], ranges: MarkdownRange[]) {
let mergedLines = [...lines];
const lineIndexes = mergedLines.map((_line, index) => index);
ranges.forEach((range) => {
const beginLineIndex = mergedLines.findLastIndex((line) => line.start <= range.start);
const endLineI... | /** Merges lines that contain multiline markdown tags into one line */ | https://github.com/Expensify/react-native-live-markdown/blob/958dbd95c635c78ce491105368b5ac45adba228e/src/web/utils/parserUtils.ts#L35-L65 | 958dbd95c635c78ce491105368b5ac45adba228e |
react-native-live-markdown | github_2023 | Expensify | typescript | appendValueToElement | function appendValueToElement(element: HTMLMarkdownElement, parentTreeNode: TreeNode, value: string) {
const targetElement = element;
const parentNode = parentTreeNode;
targetElement.value = value;
parentNode.element.value = (parentNode.element.value || '') + value;
} | /** Adds a value prop to the element and appends the value to the parent node element */ | https://github.com/Expensify/react-native-live-markdown/blob/958dbd95c635c78ce491105368b5ac45adba228e/src/web/utils/parserUtils.ts#L68-L73 | 958dbd95c635c78ce491105368b5ac45adba228e |
react-native-live-markdown | github_2023 | Expensify | typescript | parseRangesToHTMLNodes | function parseRangesToHTMLNodes(
text: string,
ranges: MarkdownRange[],
isMultiline = true,
markdownStyle: PartialMarkdownStyle = {},
disableInlineStyles = false,
currentInput: MarkdownTextInputElement | null = null,
inlineImagesProps: InlineImagesInputProps = {},
) {
const rootElement: HTMLMarkdownElem... | /** Builds HTML DOM structure based on passed text and markdown ranges */ | https://github.com/Expensify/react-native-live-markdown/blob/958dbd95c635c78ce491105368b5ac45adba228e/src/web/utils/parserUtils.ts#L140-L255 | 958dbd95c635c78ce491105368b5ac45adba228e |
altcha | github_2023 | altcha-org | typescript | PluginAnalytics.constructor | constructor(context: PluginContext) {
super(context);
this.#elForm = this.context.el.closest('form');
if (this.#elForm) {
let beaconUrl = this.#elForm.getAttribute('data-beacon-url');
const action = this.#elForm.getAttribute('action');
if (!beaconUrl && action) {
beaconUrl = action... | /**
* Creates an instance of PluginAnalytics.
*
* @param {PluginContext} context - The context object containing plugin configurations.
*/ | https://github.com/altcha-org/altcha/blob/2daa1e327576075f7eb43d648b61df97669dc4e8/src/plugins/analytics.ts#L26-L38 | 2daa1e327576075f7eb43d648b61df97669dc4e8 |
altcha | github_2023 | altcha-org | typescript | PluginAnalytics.destroy | destroy() {
this.#elForm?.removeEventListener('submit', this.#_onFormSubmit);
this.#session?.destroy();
} | /**
* Destroys the plugin instance, removing event listeners and cleaning up the session.
*/ | https://github.com/altcha-org/altcha/blob/2daa1e327576075f7eb43d648b61df97669dc4e8/src/plugins/analytics.ts#L43-L46 | 2daa1e327576075f7eb43d648b61df97669dc4e8 |
altcha | github_2023 | altcha-org | typescript | PluginAnalytics.onErrorChange | onErrorChange(err: string | null): void {
this.#session?.trackError(err);
} | /**
* Tracks errors by forwarding them to the session instance.
*
* @param {string | null} err - The error message, or `null` if no error exists.
*/ | https://github.com/altcha-org/altcha/blob/2daa1e327576075f7eb43d648b61df97669dc4e8/src/plugins/analytics.ts#L53-L55 | 2daa1e327576075f7eb43d648b61df97669dc4e8 |
altcha | github_2023 | altcha-org | typescript | Session.constructor | constructor(
readonly elForm: HTMLFormElement,
public beaconUrl: string | null = null
) {
window.addEventListener('unload', this.#onUnload);
this.elForm.addEventListener('change', this.#onFormChange);
this.elForm.addEventListener('focusin', this.#onFormFocus);
} | /**
* Creates a new Session instance.
*
* @param {HTMLFormElement} elForm - The form element being tracked.
* @param {string | null} [beaconUrl=null] - The URL to send analytics data to.
*/ | https://github.com/altcha-org/altcha/blob/2daa1e327576075f7eb43d648b61df97669dc4e8/src/plugins/analytics.ts#L115-L122 | 2daa1e327576075f7eb43d648b61df97669dc4e8 |
altcha | github_2023 | altcha-org | typescript | Session.data | data() {
const fields = Object.entries(this.#fieldChanges);
return {
correction: fields.length
? fields.filter(([_, changes]) => changes > 1).length / fields.length ||
0
: 0,
dropoff:
!this.submitTime && !this.error && this.#lastInputName
? this.#lastInput... | /**
* Collects and returns analytics data about the form interaction.
*
* @returns {Record<string, unknown>} - An object containing analytics data.
*/ | https://github.com/altcha-org/altcha/blob/2daa1e327576075f7eb43d648b61df97669dc4e8/src/plugins/analytics.ts#L129-L146 | 2daa1e327576075f7eb43d648b61df97669dc4e8 |
altcha | github_2023 | altcha-org | typescript | Session.dataAsBase64 | dataAsBase64() {
try {
return btoa(JSON.stringify(this.data()));
} catch (err) {
console.error('failed to encode ALTCHA session data to base64', err);
}
return '';
} | /**
* Encodes the session data as a base64 string.
*
* @returns {string} - The base64-encoded session data.
*/ | https://github.com/altcha-org/altcha/blob/2daa1e327576075f7eb43d648b61df97669dc4e8/src/plugins/analytics.ts#L153-L160 | 2daa1e327576075f7eb43d648b61df97669dc4e8 |
altcha | github_2023 | altcha-org | typescript | Session.destroy | destroy() {
window.removeEventListener('unload', this.#onUnload);
this.elForm.removeEventListener('change', this.#onFormChange);
this.elForm.removeEventListener('focusin', this.#onFormFocus);
} | /**
* Destroys the session, removing event listeners.
*/ | https://github.com/altcha-org/altcha/blob/2daa1e327576075f7eb43d648b61df97669dc4e8/src/plugins/analytics.ts#L165-L169 | 2daa1e327576075f7eb43d648b61df97669dc4e8 |
altcha | github_2023 | altcha-org | typescript | Session.end | end() {
if (!this.submitTime) {
this.submitTime = Date.now();
}
} | /**
* Marks the session as ended by recording the submission time.
*/ | https://github.com/altcha-org/altcha/blob/2daa1e327576075f7eb43d648b61df97669dc4e8/src/plugins/analytics.ts#L174-L178 | 2daa1e327576075f7eb43d648b61df97669dc4e8 |
altcha | github_2023 | altcha-org | typescript | Session.getFieldName | getFieldName(el: HTMLInputElement, maxLength: number = 40) {
const group = el.getAttribute('data-group-label');
const name = el.getAttribute('name') || el.getAttribute('aria-label');
return ((group ? group + ': ' : '') + name).slice(0, maxLength);
} | /**
* Retrieves the name of a form field, including a group label if available.
*
* @param {HTMLInputElement} el - The input element.
* @param {number} [maxLength=40] - The maximum length of the field name.
* @returns {string} - The field name, truncated to `maxLength` if necessary.
*/ | https://github.com/altcha-org/altcha/blob/2daa1e327576075f7eb43d648b61df97669dc4e8/src/plugins/analytics.ts#L187-L191 | 2daa1e327576075f7eb43d648b61df97669dc4e8 |
altcha | github_2023 | altcha-org | typescript | Session.isMobile | isMobile(): boolean {
const userAgentData =
'userAgentData' in navigator && navigator.userAgentData
? (navigator.userAgentData as Record<string, unknown>)
: {};
if ('mobile' in userAgentData) {
return userAgentData.mobile === true;
}
// Fallback to user agent string analysis ... | /**
* Determines if the current device is a mobile device.
*
* @returns {boolean} - `true` if the device is mobile, otherwise `false`.
*/ | https://github.com/altcha-org/altcha/blob/2daa1e327576075f7eb43d648b61df97669dc4e8/src/plugins/analytics.ts#L198-L208 | 2daa1e327576075f7eb43d648b61df97669dc4e8 |
altcha | github_2023 | altcha-org | typescript | Session.isInput | isInput(el: HTMLElement) {
return ['INPUT', 'SELECT', 'TEXTAREA'].includes(el.tagName);
} | /**
* Checks if a given element is an input element (input, select, or textarea).
*
* @param {HTMLElement} el - The element to check.
* @returns {boolean} - `true` if the element is an input, otherwise `false`.
*/ | https://github.com/altcha-org/altcha/blob/2daa1e327576075f7eb43d648b61df97669dc4e8/src/plugins/analytics.ts#L216-L218 | 2daa1e327576075f7eb43d648b61df97669dc4e8 |
altcha | github_2023 | altcha-org | typescript | Session.onFormFieldChange | onFormFieldChange(el: HTMLInputElement) {
const name = this.getFieldName(el);
if (name) {
this.trackFieldChange(name);
}
} | /**
* Tracks changes to a specific form field.
*
* @param {HTMLInputElement} el - The input element that changed.
*/ | https://github.com/altcha-org/altcha/blob/2daa1e327576075f7eb43d648b61df97669dc4e8/src/plugins/analytics.ts#L225-L230 | 2daa1e327576075f7eb43d648b61df97669dc4e8 |
altcha | github_2023 | altcha-org | typescript | Session.onFormChange | onFormChange(ev: Event) {
const target = ev.target as HTMLInputElement | null;
if (target && this.isInput(target)) {
this.onFormFieldChange(target);
}
} | /**
* Handles form change events, tracking changes to input fields.
*
* @param {Event} ev - The change event.
*/ | https://github.com/altcha-org/altcha/blob/2daa1e327576075f7eb43d648b61df97669dc4e8/src/plugins/analytics.ts#L237-L242 | 2daa1e327576075f7eb43d648b61df97669dc4e8 |
altcha | github_2023 | altcha-org | typescript | Session.onFormFocus | onFormFocus(ev: FocusEvent) {
const target = ev.target as HTMLInputElement | null;
if (!this.startTime) {
this.start();
}
if (target && this.isInput(target)) {
const name = this.getFieldName(target);
if (name) {
this.#lastInputName = name;
}
}
} | /**
* Handles form focus events, marking the session start time and tracking the last focused field.
*
* @param {FocusEvent} ev - The focus event.
*/ | https://github.com/altcha-org/altcha/blob/2daa1e327576075f7eb43d648b61df97669dc4e8/src/plugins/analytics.ts#L249-L260 | 2daa1e327576075f7eb43d648b61df97669dc4e8 |
altcha | github_2023 | altcha-org | typescript | Session.onUnload | onUnload() {
if (
this.loadTime <= Date.now() - this.viewTimeThresholdMs &&
!this.submitTime
) {
this.sendBeacon();
}
} | /**
* Handles the window unload event, sending a beacon with session data if the form was viewed but not submitted.
*/ | https://github.com/altcha-org/altcha/blob/2daa1e327576075f7eb43d648b61df97669dc4e8/src/plugins/analytics.ts#L265-L272 | 2daa1e327576075f7eb43d648b61df97669dc4e8 |
altcha | github_2023 | altcha-org | typescript | Session.sendBeacon | async sendBeacon() {
if (this.beaconUrl && 'sendBeacon' in navigator) {
try {
navigator.sendBeacon(
new URL(this.beaconUrl, location.origin),
JSON.stringify(this.data())
);
} catch {
// noop
}
}
} | /**
* Sends a beacon with session data to the specified beacon URL.
*/ | https://github.com/altcha-org/altcha/blob/2daa1e327576075f7eb43d648b61df97669dc4e8/src/plugins/analytics.ts#L277-L288 | 2daa1e327576075f7eb43d648b61df97669dc4e8 |
altcha | github_2023 | altcha-org | typescript | Session.start | start() {
this.startTime = Date.now();
} | /**
* Marks the session as started by recording the start time.
*/ | https://github.com/altcha-org/altcha/blob/2daa1e327576075f7eb43d648b61df97669dc4e8/src/plugins/analytics.ts#L293-L295 | 2daa1e327576075f7eb43d648b61df97669dc4e8 |
altcha | github_2023 | altcha-org | typescript | Session.trackError | trackError(err: string | null) {
this.error = err === null ? null : String(err);
} | /**
* Tracks an error associated with the session.
*
* @param {string | null} err - The error message, or `null` if no error exists.
*/ | https://github.com/altcha-org/altcha/blob/2daa1e327576075f7eb43d648b61df97669dc4e8/src/plugins/analytics.ts#L302-L304 | 2daa1e327576075f7eb43d648b61df97669dc4e8 |
altcha | github_2023 | altcha-org | typescript | Session.trackFieldChange | trackFieldChange(name: string) {
this.#fieldChanges[name] = (this.#fieldChanges[name] || 0) + 1;
} | /**
* Tracks a change to a specific form field.
*
* @param {string} name - The name of the form field.
*/ | https://github.com/altcha-org/altcha/blob/2daa1e327576075f7eb43d648b61df97669dc4e8/src/plugins/analytics.ts#L311-L313 | 2daa1e327576075f7eb43d648b61df97669dc4e8 |
altcha | github_2023 | altcha-org | typescript | PluginObfuscation.constructor | constructor(context: PluginContext) {
super(context);
const el = context.el;
// Select the button that will trigger the obfuscation clarification
this.elButton =
el.parentElement?.querySelector('[data-clarify-button]') ||
(el.parentElement?.querySelector('button, a') as HTMLElement | null);... | /**
* Creates an instance of PluginObfuscation.
*
* @param {PluginContext} context - The context object containing plugin configurations.
*/ | https://github.com/altcha-org/altcha/blob/2daa1e327576075f7eb43d648b61df97669dc4e8/src/plugins/obfuscation.ts#L22-L34 | 2daa1e327576075f7eb43d648b61df97669dc4e8 |
altcha | github_2023 | altcha-org | typescript | PluginObfuscation.destroy | destroy() {
if (this.elButton) {
this.elButton.removeEventListener('click', this.#_onButtonClick);
}
} | /**
* Destroys the plugin instance, removing event listeners.
*/ | https://github.com/altcha-org/altcha/blob/2daa1e327576075f7eb43d648b61df97669dc4e8/src/plugins/obfuscation.ts#L39-L43 | 2daa1e327576075f7eb43d648b61df97669dc4e8 |
altcha | github_2023 | altcha-org | typescript | PluginObfuscation.clarify | async clarify() {
const {
el,
getConfiguration,
getFloatingAnchor,
setFloatingAnchor,
reset,
solve,
setState,
} = this.context;
const { delay, floating, maxnumber, obfuscated } = getConfiguration();
// Set the floating anchor to the button if not already set
... | /**
* Handles the clarification process by decrypting the obfuscated data and rendering the clear text.
*/ | https://github.com/altcha-org/altcha/blob/2daa1e327576075f7eb43d648b61df97669dc4e8/src/plugins/obfuscation.ts#L48-L107 | 2daa1e327576075f7eb43d648b61df97669dc4e8 |
altcha | github_2023 | altcha-org | typescript | PluginUpload.constructor | constructor(context: PluginContext) {
super(context);
this.elForm = this.context.el.closest('form');
if (this.elForm) {
this.elForm.addEventListener('change', this.#_onFormChange);
this.elForm.addEventListener('submit', this.#_onFormSubmit, {
capture: true,
});
}
} | /**
* Constructor initializes the plugin, setting up event listeners on the form.
*
* @param {PluginContext} context - Plugin context providing access to the element, configuration, and utility methods.
*/ | https://github.com/altcha-org/altcha/blob/2daa1e327576075f7eb43d648b61df97669dc4e8/src/plugins/upload.ts#L37-L46 | 2daa1e327576075f7eb43d648b61df97669dc4e8 |
altcha | github_2023 | altcha-org | typescript | PluginUpload.addFile | addFile(fieldName: string, file: File) {
if (
!this.pendingFiles.find(([name, f]) => name === fieldName && f === file)
) {
this.pendingFiles.push([fieldName, file]);
}
} | /**
* Adds a file to the pending files list for upload.
*
* @param {string} fieldName - The field name associated with the file input.
* @param {File} file - The file to be uploaded.
*/ | https://github.com/altcha-org/altcha/blob/2daa1e327576075f7eb43d648b61df97669dc4e8/src/plugins/upload.ts#L54-L60 | 2daa1e327576075f7eb43d648b61df97669dc4e8 |
altcha | github_2023 | altcha-org | typescript | PluginUpload.destroy | destroy() {
if (this.elForm) {
this.elForm.removeEventListener('change', this.#_onFormChange);
this.elForm.removeEventListener('submit', this.#_onFormSubmit);
}
} | /**
* Cleans up event listeners and other resources when the plugin is destroyed.
*/ | https://github.com/altcha-org/altcha/blob/2daa1e327576075f7eb43d648b61df97669dc4e8/src/plugins/upload.ts#L65-L70 | 2daa1e327576075f7eb43d648b61df97669dc4e8 |
altcha | github_2023 | altcha-org | typescript | PluginUpload.uploadPendingFiles | async uploadPendingFiles() {
const next = async () => {
const entry = this.pendingFiles[0];
if (entry) {
await this.#uploadFile(this.#createUploadHandle(entry));
}
if (this.pendingFiles.length) {
return next();
}
};
await next();
if (this.pendingFiles.length... | /**
* Uploads all pending files in the list.
*/ | https://github.com/altcha-org/altcha/blob/2daa1e327576075f7eb43d648b61df97669dc4e8/src/plugins/upload.ts#L75-L90 | 2daa1e327576075f7eb43d648b61df97669dc4e8 |
altcha | github_2023 | altcha-org | typescript | UploadHandle.constructor | constructor(
readonly fieldName: string,
readonly file: File
) {
this.uploadSize = this.file.size;
this.promise = new Promise((resolve, reject) => {
this.resolve = resolve;
this.reject = reject;
});
} | /**
* Creates an instance of UploadHandle.
*
* @param {string} fieldName - The name of the field associated with the file upload.
* @param {File} file - The file to be uploaded.
*/ | https://github.com/altcha-org/altcha/blob/2daa1e327576075f7eb43d648b61df97669dc4e8/src/plugins/upload.ts#L425-L434 | 2daa1e327576075f7eb43d648b61df97669dc4e8 |
altcha | github_2023 | altcha-org | typescript | UploadHandle.abort | abort() {
this.controller.abort();
} | /**
* Aborts the file upload by invoking the AbortController's abort method.
*/ | https://github.com/altcha-org/altcha/blob/2daa1e327576075f7eb43d648b61df97669dc4e8/src/plugins/upload.ts#L439-L441 | 2daa1e327576075f7eb43d648b61df97669dc4e8 |
altcha | github_2023 | altcha-org | typescript | UploadHandle.setProgress | setProgress(loaded: number) {
this.loaded = loaded;
this.progress =
this.file.size && loaded ? Math.min(1, loaded / this.file.size) : 0;
} | /**
* Updates the progress of the file upload.
*
* @param {number} loaded - The number of bytes that have been uploaded.
*/ | https://github.com/altcha-org/altcha/blob/2daa1e327576075f7eb43d648b61df97669dc4e8/src/plugins/upload.ts#L448-L452 | 2daa1e327576075f7eb43d648b61df97669dc4e8 |
Gomoon | github_2023 | wizardAEI | typescript | removeChineseSpaces | function removeChineseSpaces(str) {
return str
.replace(/([\u4e00-\u9fa5])\s+/g, '$1')
.replace(/\s+([\u4e00-\u9fa5])/g, '$1')
} | // 去掉中文的空格 | https://github.com/wizardAEI/Gomoon/blob/5c8904e9f072d27f906819dbe2d11770a0564014/src/renderer/src/components/MainInput/Tools.tsx#L265-L269 | 5c8904e9f072d27f906819dbe2d11770a0564014 |
Gomoon | github_2023 | wizardAEI | typescript | watchSelection | const watchSelection = (e: MouseEvent) => {
if (e.target === textAreaDiv) {
setHaveSelected(window.getSelection()?.toString() !== '')
}
} | // 监测是否划选 | https://github.com/wizardAEI/Gomoon/blob/5c8904e9f072d27f906819dbe2d11770a0564014/src/renderer/src/components/MainInput/index.tsx#L303-L307 | 5c8904e9f072d27f906819dbe2d11770a0564014 |
Gomoon | github_2023 | wizardAEI | typescript | showContextContainer | const showContextContainer = (e) => {
setShowContext(true)
// 将contextContainer定位到鼠标位置, 如果超出屏幕,则调整到合适位置
contextContainer!.style.left =
e.clientX + contextContainer!.offsetWidth > window.innerWidth
? `${e.clientX - contextContainer!.offsetWidth}px`
: `${e.clientX}px`
c... | // 显示和隐藏右键菜单 | https://github.com/wizardAEI/Gomoon/blob/5c8904e9f072d27f906819dbe2d11770a0564014/src/renderer/src/components/MainInput/index.tsx#L310-L322 | 5c8904e9f072d27f906819dbe2d11770a0564014 |
Gomoon | github_2023 | wizardAEI | typescript | addActive | const addActive = () => {
textAreaContainerDiv!.attributes.setNamedItem(document.createAttribute('data-active'))
} | // 让input聚焦,box边框变为激活色 | https://github.com/wizardAEI/Gomoon/blob/5c8904e9f072d27f906819dbe2d11770a0564014/src/renderer/src/components/MainInput/index.tsx#L325-L327 | 5c8904e9f072d27f906819dbe2d11770a0564014 |
Gomoon | github_2023 | wizardAEI | typescript | showButton | const showButton = (e: MouseEvent) => {
const selection = window.getSelection()
!showSearch() && setFindContent('')
if (selection) {
if (selection.toString().length > 0) {
setShowSelectBtn(true)
btn!.style.top = `${e.clientY - 20}px`
btn!.style.left = `${e.clientX... | // FEAT: 用户滑动选择文本 | https://github.com/wizardAEI/Gomoon/blob/5c8904e9f072d27f906819dbe2d11770a0564014/src/renderer/src/components/Message/Md.tsx#L122-L139 | 5c8904e9f072d27f906819dbe2d11770a0564014 |
Gomoon | github_2023 | wizardAEI | typescript | highlightText | function highlightText(node: any) {
if (!findContent()) return
$(node)
.contents()
.each(function (_, elem) {
if (elem.type === 'text') {
// 如果是文本节点,则替换文本
const text = $(elem).text()
// 检查是否有匹配
const regExp = new RegExp(escapeRegExp(f... | // FEAT: 对findContent高亮 | https://github.com/wizardAEI/Gomoon/blob/5c8904e9f072d27f906819dbe2d11770a0564014/src/renderer/src/components/Message/Md.tsx#L215-L238 | 5c8904e9f072d27f906819dbe2d11770a0564014 |
Gomoon | github_2023 | wizardAEI | typescript | callLLMFromNode | const callLLMFromNode = (
msgs: {
role: Roles
content: MessageContent
}[],
option: {
newTokenCallback: (content: string) => void
endCallback?: (result: LLMResult) => void
errorCallback?: (err: unknown) => void
pauseSignal: AbortSignal
}
) =>
new Promise((resolve, reject) => {
const... | // TODO: 读取 assistant 信息来生成,可以从本地读取,也可以从远程读取 | https://github.com/wizardAEI/Gomoon/blob/5c8904e9f072d27f906819dbe2d11770a0564014/src/renderer/src/lib/ai/langchain/index.ts#L97-L133 | 5c8904e9f072d27f906819dbe2d11770a0564014 |
LafTools | github_2023 | work7z | typescript | shuffleArrayMutate | function shuffleArrayMutate<T>(array: T[]): T[] {
for (let i = array.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[array[i], array[j]] = [array[j], array[i]];
}
return array;
} | // Durstenfeld shuffle | https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/addons/it-tools/src/utils/random.ts#L8-L15 | ec1910c3ddf2827b529e4e1f0bed06d762f33b4a |
LafTools | github_2023 | work7z | typescript | sleep | let sleep = (ms: number) =>
new Promise((resolve) => setTimeout(resolve, ms)); | // randomly sleep in 1 seconds | https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/legacy/node/src/ext/job.ts#L46-L47 | ec1910c3ddf2827b529e4e1f0bed06d762f33b4a |
LafTools | github_2023 | work7z | typescript | getLocale | function getLocale(request: NextRequest) {
let acceptLanguage = _.toLower(request.headers.get("accept-language") + "");
let val = defaultLocale.langInHttp;
let ack = false;
rever_locales_http.every((locale) => {
_.every(locale, (x) => {
if (acceptLanguage?.includes(x)) {
val = _.first(locale) ... | // Get the preferred locale, similar to the above or using a library | https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/middleware.ts#L69-L84 | ec1910c3ddf2827b529e4e1f0bed06d762f33b4a |
LafTools | github_2023 | work7z | typescript | fn | let fn = (obj: Partial<Metadata>) => {
return _.merge({
icons: [
'/icon.png'
],
title: Dot("title-laftools", "LafTools - The Leading All-In-One ToolBox for Programmers"),
description: Dot("iZXig7E2JF", "LafTools offers a comprehensive suite of deve... | // fn | https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/page.tsx#L91-L100 | ec1910c3ddf2827b529e4e1f0bed06d762f33b4a |
LafTools | github_2023 | work7z | typescript | EntryWrapper | const EntryWrapper = () => <div>deprecated</div>
let cachedLangMap: { [key: string]: string } = {} | // const EntryWrapper = dynamic(() => import('./client'), { ssr: false, loading: () => <PageLoadingEffect /> }) | https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/page.tsx#L25-L27 | ec1910c3ddf2827b529e4e1f0bed06d762f33b4a |
LafTools | github_2023 | work7z | typescript | formatEachNodeItem | let formatEachNodeItem = (nodeList: TreeNodeInfo[]): TreeNodeInfo[] => {
return _.map(nodeList, (x) => {
let rootLevel = (x.id + "").indexOf(TREE_ROOT_ID_PREFIX) == 0;
let hasCaret = !_.isNil(x.hasCaret)
? x.hasCaret
: !_.isEmpty(x.childNodes);
let isExpanded = hasSearc... | // recursively format tmp_nodes to nodes, so that we can use it in Tree, note that isExpanded is true when it's in props.expanded and isSeleced is true when it's in props.selected | https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/components/SystemNavTree/index.tsx#L113-L144 | ec1910c3ddf2827b529e4e1f0bed06d762f33b4a |
LafTools | github_2023 | work7z | typescript | AND.constructor | constructor() {
super();
this.name = Dot("and.name", "AND");
this.module = "Default";
this.description = Dot("and.desc", "AND the input with the given key. e.g. fe023da5");
this.infoURL = "https://wikipedia.org/wiki/Bitwise_operation#AND";
this.inputType = "byteArray";
this.outputType = "by... | /**
* AND constructor
*/ | https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/AND.tsx#L19-L36 | ec1910c3ddf2827b529e4e1f0bed06d762f33b4a |
LafTools | github_2023 | work7z | typescript | AND.getOptDetail | public getOptDetail(): OptDetail {
return {
relatedID: 'nothing',
config: {
"module": "Default",
"description": this.description,
"infoURL": this.infoURL,
"inputType": this.inputType,
"outputType": this.outputType,
"flowControl": false,
"manualBake... | /**
* Get operation details
*/ | https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/AND.tsx#L41-L66 | ec1910c3ddf2827b529e4e1f0bed06d762f33b4a |
LafTools | github_2023 | work7z | typescript | AND.run | run(input: Uint8Array, args: any[]): Uint8Array {
const key = Utils.convertToByteArray(args[0].string || "", args[0].option);
return bitOp(input, key, and);
} | /**
* @param {Uint8Array} input
* @param {Object[]} args
* @returns {Uint8Array}
*/ | https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/AND.tsx#L73-L77 | ec1910c3ddf2827b529e4e1f0bed06d762f33b4a |
LafTools | github_2023 | work7z | typescript | AND.highlight | highlight(pos: { start: number; end: number }[], args: any[]): { start: number; end: number }[] {
return pos;
} | /**
* Highlight AND
*
* @param {Object[]} pos
* @param {number} pos[].start
* @param {number} pos[].end
* @param {Object[]} args
* @returns {Object[]} pos
*/ | https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/AND.tsx#L88-L90 | ec1910c3ddf2827b529e4e1f0bed06d762f33b4a |
LafTools | github_2023 | work7z | typescript | AND.highlightReverse | highlightReverse(pos: { start: number; end: number }[], args: any[]): { start: number; end: number }[] {
return pos;
} | /**
* Highlight AND in reverse
*
* @param {Object[]} pos
* @param {number} pos[].start
* @param {number} pos[].end
* @param {Object[]} args
* @returns {Object[]} pos
*/ | https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/AND.tsx#L101-L103 | ec1910c3ddf2827b529e4e1f0bed06d762f33b4a |
LafTools | github_2023 | work7z | typescript | CSSBeautify.constructor | constructor() {
super();
this.module = "Code";
this.inputType = "string";
this.outputType = "string";
this.args = [
{
"name": Dot("isti", "Indent string"),
"type": "binaryShortString",
"value": "\\t"
}
... | /**
* CSSBeautify constructor
*/ | https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/CSSBeautify.tsx#L61-L75 | ec1910c3ddf2827b529e4e1f0bed06d762f33b4a |
LafTools | github_2023 | work7z | typescript | CSSBeautify.run | run(input, args) {
let indentStr = gutils.convertASCIICodeInStr(args[0]);
return vkbeautify.css(input, indentStr);
} | /**
* @param {string} input
* @param {Object[]} args
* @returns {string}
*/ | https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/CSSBeautify.tsx#L82-L85 | ec1910c3ddf2827b529e4e1f0bed06d762f33b4a |
LafTools | github_2023 | work7z | typescript | CSSMinify.constructor | constructor() {
super();
this.module = "Code";
this.inputType = "string";
this.outputType = "string";
this.args = [
{
name: "Preserve comments",
type: "boolean",
value: false,
},
];
} | /**
* CSSMinify constructor
*/ | https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/CSSMinify.tsx#L59-L74 | ec1910c3ddf2827b529e4e1f0bed06d762f33b4a |
LafTools | github_2023 | work7z | typescript | CSSMinify.run | run(input, args) {
const preserveComments = args[0];
return vkbeautify.cssmin(input, preserveComments);
} | /**
* @param {string} input
* @param {Object[]} args
* @returns {string}
*/ | https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/CSSMinify.tsx#L81-L84 | ec1910c3ddf2827b529e4e1f0bed06d762f33b4a |
LafTools | github_2023 | work7z | typescript | CSVToJSON.constructor | constructor() {
super();
this.outputType = "JSON";
this.inputType = "string";
this.args = [
{
name: "Cell delimiters",
type: "binaryShortString",
value: ",",
},
{
name: "Row delimiters",
type: "binaryShortString",
value: "\\r\\n",
}... | /**
* CSVToJSON constructor
*/ | https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/CSVToJSON.tsx#L74-L96 | ec1910c3ddf2827b529e4e1f0bed06d762f33b4a |
LafTools | github_2023 | work7z | typescript | CSVToJSON.run | run(input, args) {
const [cellDelims, rowDelims, format] = args;
let json, header;
try {
json = Utils.parseCSV(input, cellDelims.split(""), rowDelims.split(""));
} catch (err) {
throw new OperationError("Unable to parse CSV: " + err);
}
switch (format) {
case "Array of dictio... | /**
* @param {string} input
* @param {Object[]} args
* @returns {JSON}
*/ | https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/CSVToJSON.tsx#L103-L127 | ec1910c3ddf2827b529e4e1f0bed06d762f33b4a |
LafTools | github_2023 | work7z | typescript | FromBCD.constructor | constructor() {
super();
this.module = "Default"
this.inputType = "string";
this.outputType = "BigNumber";
this.args = [
{
name: "Scheme",
type: "option",
value: ENCODING_SCHEME,
},
{
name: "Packed",
type: "boolean",
value: true,
... | /**
* FromBCD constructor
*/ | https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/FromBCD.tsx#L98-L132 | ec1910c3ddf2827b529e4e1f0bed06d762f33b4a |
LafTools | github_2023 | work7z | typescript | FromBCD.run | run(input, args) {
const encoding = ENCODING_LOOKUP[args[0]],
packed = args[1],
signed = args[2],
inputFormat = args[3],
nibbles: any = [];
let output = "",
byteArray;
// Normalise the input
switch (inputFormat) {
case "Nibbles":
case "Bytes":
input = ... | /**
* @param {string} input
* @param {Object[]} args
* @returns {BigNumber}
*/ | https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/FromBCD.tsx#L139-L194 | ec1910c3ddf2827b529e4e1f0bed06d762f33b4a |
LafTools | github_2023 | work7z | typescript | FromBase32.constructor | constructor() {
super();
this.name = "From Base32";
this.module = "Default";
this.inputType = "string";
this.outputType = "byteArray";
this.args = [
{
name: Dot("skq3i12", "Alphabet"),
type: "binaryString",
va... | /**
* FromBase32 constructor
*/ | https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/FromBase32.tsx#L78-L106 | ec1910c3ddf2827b529e4e1f0bed06d762f33b4a |
LafTools | github_2023 | work7z | typescript | FromBase32.run | run(input, args) {
if (!input) return [];
const alphabet = args[0] ?
Utils.expandAlphRange(args[0]).join("") : "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",
removeNonAlphChars = args[1],
output: any[] = [];
let chr1, chr2, chr3, chr4, chr5,
enc1, enc2, en... | /**
* @param {string} input
* @param {Object[]} args
* @returns {byteArray}
*/ | https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/FromBase32.tsx#L113-L154 | ec1910c3ddf2827b529e4e1f0bed06d762f33b4a |
LafTools | github_2023 | work7z | typescript | FromBase45.constructor | constructor() {
super();
this.name = "From Base45";
this.module = "Default";
this.inputType = "string";
this.outputType = "byteArray";
this.args = [
{
name: Dot("skq3i12", "Alphabet"),
type: "string",
value: ALP... | /**
* FromBase45 constructor
*/ | https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/FromBase45.tsx#L71-L97 | ec1910c3ddf2827b529e4e1f0bed06d762f33b4a |
LafTools | github_2023 | work7z | typescript | FromBase45.run | run(input, args) {
if (!input) return [];
const alphabet = Utils.expandAlphRange(args[0]).join("");
const removeNonAlphChars = args[1];
const res: any = [];
// Remove non-alphabet characters
if (removeNonAlphChars) {
const re = new RegExp("[^" + alphabet.rep... | /**
* @param {string} input
* @param {Object[]} args
* @returns {byteArray}
*/ | https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/FromBase45.tsx#L104-L149 | ec1910c3ddf2827b529e4e1f0bed06d762f33b4a |
LafTools | github_2023 | work7z | typescript | FromBase58.constructor | constructor() {
super();
this.module = "Default";
// this.description = ;
// this.infoURL = "";
this.inputType = "string";
this.outputType = "byteArray";
this.args = [
{
"name": Dot("anosdk", "Alphabet"),
"type": "edita... | /**
* FromBase58 constructor
*/ | https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/FromBase58.tsx#L96-L133 | ec1910c3ddf2827b529e4e1f0bed06d762f33b4a |
LafTools | github_2023 | work7z | typescript | FromBase58.run | run(input, args) {
let alphabet = args[0] || ALPHABET_OPTIONS[0].value;
const removeNonAlphaChars = args[1] === undefined ? true : args[1],
result = [0];
alphabet = Utils.expandAlphRange(alphabet).join("");
if (alphabet.length !== 58 ||
([] as any).unique.call(a... | /**
* @param {string} input
* @param {Object[]} args
* @returns {byteArray}
*/ | https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/FromBase58.tsx#L140-L191 | ec1910c3ddf2827b529e4e1f0bed06d762f33b4a |
LafTools | github_2023 | work7z | typescript | FromBase62.constructor | constructor() {
super();
this.name = "From Base62";
this.module = "Default";
// this.description = "";
// this.infoURL = "https://wikipedia.org/wiki/List_of_numeral_systems";
this.inputType = "string";
this.outputType = "byteArray";
this.args = [
... | /**
* FromBase62 constructor
*/ | https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/FromBase62.tsx#L68-L88 | ec1910c3ddf2827b529e4e1f0bed06d762f33b4a |
LafTools | github_2023 | work7z | typescript | FromBase62.run | run(input, args) {
if (input.length < 1) return [];
const alphabet = Utils.expandAlphRange(args[0]).join("");
const BN62 = BigNumber.clone({ ALPHABET: alphabet });
const re = new RegExp("[^" + alphabet.replace(/[[\]\\\-^$]/g, "\\$&") + "]", "g");
input = input.replace(re, "");
... | /**
* @param {string} input
* @param {Object[]} args
* @returns {byteArray}
*/ | https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/FromBase62.tsx#L95-L113 | ec1910c3ddf2827b529e4e1f0bed06d762f33b4a |
LafTools | github_2023 | work7z | typescript | FromBase64.constructor | constructor() {
super();
this.module = "Default";
this.inputType = "string";
this.outputType = "byteArray";
this.args = [
{
name: Dot("skq3i12", "Alphabet"),
type: "editableOption",
value: ALPHABET_OPTIONS,
},
{
name: Dot("nskqw", "Remove non-alp... | /**
* FromBase64 constructor
*/ | https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/FromBase64.tsx#L291-L431 | ec1910c3ddf2827b529e4e1f0bed06d762f33b4a |
LafTools | github_2023 | work7z | typescript | FromBase64.run | run(input, args) {
const [alphabet, removeNonAlphChars, strictMode] = args;
return fromBase64(
input,
alphabet,
"byteArray",
removeNonAlphChars,
strictMode,
);
} | /**
* @param {string} input
* @param {Object[]} args
* @returns {byteArray}
*/ | https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/FromBase64.tsx#L438-L448 | ec1910c3ddf2827b529e4e1f0bed06d762f33b4a |
LafTools | github_2023 | work7z | typescript | FromBase64.highlight | highlight(pos, args) {
pos[0].start = Math.ceil((pos[0].start / 4) * 3);
pos[0].end = Math.floor((pos[0].end / 4) * 3);
return pos;
} | /**
* Highlight to Base64
*
* @param {Object[]} pos
* @param {number} pos[].start
* @param {number} pos[].end
* @param {Object[]} args
* @returns {Object[]} pos
*/ | https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/FromBase64.tsx#L459-L463 | ec1910c3ddf2827b529e4e1f0bed06d762f33b4a |
LafTools | github_2023 | work7z | typescript | FromBase64.highlightReverse | highlightReverse(pos, args) {
pos[0].start = Math.floor((pos[0].start / 3) * 4);
pos[0].end = Math.ceil((pos[0].end / 3) * 4);
return pos;
} | /**
* Highlight from Base64
*
* @param {Object[]} pos
* @param {number} pos[].start
* @param {number} pos[].end
* @param {Object[]} args
* @returns {Object[]} pos
*/ | https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/FromBase64.tsx#L474-L478 | ec1910c3ddf2827b529e4e1f0bed06d762f33b4a |
LafTools | github_2023 | work7z | typescript | FromBase85.constructor | constructor() {
super();
this.name = "From Base85";
this.module = "Default";
// this.description = ;
// this.infoURL = "";
this.inputType = "string";
this.outputType = "byteArray";
this.args = [
{
name: Dot("skq3i12", "Alp... | /**
* From Base85 constructor
*/ | https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/FromBase85.tsx#L112-L173 | ec1910c3ddf2827b529e4e1f0bed06d762f33b4a |
LafTools | github_2023 | work7z | typescript | FromBase85.run | run(input, args) {
const alphabet = Utils.expandAlphRange(args[0]).join(""),
removeNonAlphChars = args[1],
allZeroGroupChar = typeof args[2] === "string" ? args[2].slice(0, 1) : "",
result: any = [];
if (alphabet.length !== 85 ||
([] as any).unique.call(a... | /**
* @param {string} input
* @param {Object[]} args
* @returns {byteArray}
*/ | https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/FromBase85.tsx#L180-L253 | ec1910c3ddf2827b529e4e1f0bed06d762f33b4a |
LafTools | github_2023 | work7z | typescript | FromBinary.constructor | constructor() {
super();
this.name = "From Binary";
this.module = "Default";
this.inputType = "string";
this.outputType = "byteArray";
this.args = [
{
name: "Delimiter",
type: "option",
value: BIN_DELIM_OPTIONS,
},
{
name: "Byte Length",
... | /**
* FromBinary constructor
*/ | https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/FromBinary.tsx#L76-L133 | ec1910c3ddf2827b529e4e1f0bed06d762f33b4a |
LafTools | github_2023 | work7z | typescript | FromBinary.run | run(input, args) {
const byteLen = args[1] ? args[1] : 8;
return fromBinary(input, args[0], byteLen);
} | /**
* @param {string} input
* @param {Object[]} args
* @returns {byteArray}
*/ | https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/FromBinary.tsx#L140-L143 | ec1910c3ddf2827b529e4e1f0bed06d762f33b4a |
LafTools | github_2023 | work7z | typescript | FromBinary.highlight | highlight(pos, args) {
const delim = Utils.charRep(args[0] || "Space");
pos[0].start =
pos[0].start === 0 ? 0 : Math.floor(pos[0].start / (8 + delim.length));
pos[0].end =
pos[0].end === 0 ? 0 : Math.ceil(pos[0].end / (8 + delim.length));
return pos;
} | /**
* Highlight From Binary
*
* @param {Object[]} pos
* @param {number} pos[].start
* @param {number} pos[].end
* @param {Object[]} args
* @returns {Object[]} pos
*/ | https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/FromBinary.tsx#L154-L161 | ec1910c3ddf2827b529e4e1f0bed06d762f33b4a |
LafTools | github_2023 | work7z | typescript | FromBinary.highlightReverse | highlightReverse(pos, args) {
const delim = Utils.charRep(args[0] || "Space");
pos[0].start = pos[0].start * (8 + delim.length);
pos[0].end = pos[0].end * (8 + delim.length) - delim.length;
return pos;
} | /**
* Highlight From Binary in reverse
*
* @param {Object[]} pos
* @param {number} pos[].start
* @param {number} pos[].end
* @param {Object[]} args
* @returns {Object[]} pos
*/ | https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/FromBinary.tsx#L172-L177 | ec1910c3ddf2827b529e4e1f0bed06d762f33b4a |
LafTools | github_2023 | work7z | typescript | FromCharcode.constructor | constructor() {
super();
this.name = "From Charcode";
this.module = "Default";
this.inputType = "string";
this.outputType = "ArrayBuffer";
this.args = [
{
name: "Delimiter",
type: "option",
value: DELIM_OPTIONS,
},
{
name: "Base",
type: ... | /**
* FromCharcode constructor
*/ | https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/FromCharcode.tsx#L64-L83 | ec1910c3ddf2827b529e4e1f0bed06d762f33b4a |
LafTools | github_2023 | work7z | typescript | FromCharcode.run | run(input, args) {
const delim = Utils.charRep(args[0] || "Space"),
base = args[1];
let bites = input.split(delim),
i = 0;
if (base < 2 || base > 36) {
throw new OperationError("Error: Base argument must be between 2 and 36");
}
if (input.length === 0) {
return new ArrayBuf... | /**
* @param {string} input
* @param {Object[]} args
* @returns {ArrayBuffer}
*
* @throws {OperationError} if base out of range
*/ | https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/FromCharcode.tsx#L92-L123 | ec1910c3ddf2827b529e4e1f0bed06d762f33b4a |
LafTools | github_2023 | work7z | typescript | FromDecimal.constructor | constructor() {
super();
this.name = "From Decimal";
this.module = "Default";
// this.description =
// "Converts the data from an ordinal integer array back into its raw form.<br><br>e.g. <code>72 101 108 108 111</code> becomes <code>Hello</code>";
this.inputType = "string";
this.outputTy... | /**
* FromDecimal constructor
*/ | https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/FromDecimal.tsx#L95-L154 | ec1910c3ddf2827b529e4e1f0bed06d762f33b4a |
LafTools | github_2023 | work7z | typescript | FromDecimal.run | run(input, args) {
let data = fromDecimal(input, args[0]);
if (args[1]) {
// Convert negatives
data = data.map((v) => (v < 0 ? 0xff + v + 1 : v));
}
return data;
} | /**
* @param {string} input
* @param {Object[]} args
* @returns {byteArray}
*/ | https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/FromDecimal.tsx#L161-L168 | ec1910c3ddf2827b529e4e1f0bed06d762f33b4a |
LafTools | github_2023 | work7z | typescript | FromHTMLEntity.constructor | constructor() {
super();
this.name = "From HTML Entity";
this.module = "Encodings";
this.inputType = "string";
this.outputType = "string";
this.args = [];
this.checks = [
{
pattern: "&(?:#\\d{2,3}|#x[\\da-f]{2}|[a-z]{2,6});",
flags: "i",
args: [],
},
... | /**
* FromHTMLEntity constructor
*/ | https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/FromHTMLEntity.tsx#L46-L61 | ec1910c3ddf2827b529e4e1f0bed06d762f33b4a |
LafTools | github_2023 | work7z | typescript | FromHTMLEntity.run | run(input, args) {
const regex = /&(#?x?[a-zA-Z0-9]{1,20});/g;
let output = "",
m,
i = 0;
while ((m = regex.exec(input))) {
// Add up to match
for (; i < m.index;) output += input[i++];
// Add match
const bite = entityToByte[m[1]];
if (bite) {
output += Ut... | /**
* @param {string} input
* @param {Object[]} args
* @returns {string}
*/ | https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/FromHTMLEntity.tsx#L68-L111 | ec1910c3ddf2827b529e4e1f0bed06d762f33b4a |
LafTools | github_2023 | work7z | typescript | FromHex.constructor | constructor() {
super();
this.module = "Default";
this.inputType = "string"
this.outputType = "byteArray"
this.args = [
{
name: "Delimiter",
type: "option",
value: FROM_HEX_DELIM_OPTIONS,
},
];
this.checks = [
{
pattern: "^(?:[\\dA-F]{2})+... | /**
* FromHex constructor
*/ | https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/FromHex.tsx#L142-L209 | ec1910c3ddf2827b529e4e1f0bed06d762f33b4a |
LafTools | github_2023 | work7z | typescript | FromHex.run | run(input, args) {
const delim = args[0] || "Auto";
return fromHex(input, delim, 2);
} | /**
* @param {string} input
* @param {Object[]} args
* @returns {byteArray}
*/ | https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/FromHex.tsx#L216-L219 | ec1910c3ddf2827b529e4e1f0bed06d762f33b4a |
LafTools | github_2023 | work7z | typescript | FromHex.highlight | highlight(pos, args) {
if (args[0] === "Auto") return false;
const delim = Utils.charRep(args[0] || "Space"),
len = delim === "\r\n" ? 1 : delim.length,
width = len + 2;
// 0x and \x are added to the beginning if they are selected, so increment the positions accordingly
if (delim === "0x" |... | /**
* Highlight to Hex
*
* @param {Object[]} pos
* @param {number} pos[].start
* @param {number} pos[].end
* @param {Object[]} args
* @returns {Object[]} pos
*/ | https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/FromHex.tsx#L230-L247 | ec1910c3ddf2827b529e4e1f0bed06d762f33b4a |
LafTools | github_2023 | work7z | typescript | FromHex.highlightReverse | highlightReverse(pos, args) {
const delim = Utils.charRep(args[0] || "Space"),
len = delim === "\r\n" ? 1 : delim.length;
pos[0].start = pos[0].start * (2 + len);
pos[0].end = pos[0].end * (2 + len) - len;
// 0x and \x are added to the beginning if they are selected, so increment the positions a... | /**
* Highlight from Hex
*
* @param {Object[]} pos
* @param {number} pos[].start
* @param {number} pos[].end
* @param {Object[]} args
* @returns {Object[]} pos
*/ | https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/FromHex.tsx#L258-L271 | ec1910c3ddf2827b529e4e1f0bed06d762f33b4a |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.