Skip to content

Commit

Permalink
Merge branch 'release/v0.24.23'
Browse files Browse the repository at this point in the history
  • Loading branch information
holtwick committed Oct 10, 2024
2 parents b9d8485 + ad6e2c1 commit 396a969
Show file tree
Hide file tree
Showing 8 changed files with 24 additions and 24 deletions.
14 changes: 7 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "zeed",
"type": "module",
"version": "0.24.22",
"version": "0.24.23",
"description": "🌱 Simple foundation library",
"author": {
"name": "Dirk Holtwick",
Expand Down Expand Up @@ -71,17 +71,17 @@
"devDependencies": {
"@antfu/eslint-config": "^3.7",
"@antfu/ni": "^0.23.0",
"@types/node": "^22.7.2",
"@types/node": "^22.7.5",
"@vitejs/plugin-vue": "^5.1.4",
"@vitest/browser": "^2.1.1",
"@vitest/coverage-v8": "^2.1.1",
"@vitest/browser": "^2.1.2",
"@vitest/coverage-v8": "^2.1.2",
"esbuild": "^0.24.0",
"eslint": "^9",
"playwright": "^1.47.2",
"playwright": "^1.48.0",
"tsup": "^8.3.0",
"typescript": "^5.6.2",
"typescript": "^5.6.3",
"vite": "^5.4.8",
"vitest": "^2.1.1"
"vitest": "^2.1.2"
},
"pnpm": {
"overrides": {
Expand Down
6 changes: 3 additions & 3 deletions src/common/csv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,17 @@ export function csvParse(raw: string, opt: {
// eslint-disable-next-line regexp/no-unused-capturing-group, regexp/no-super-linear-backtracking, regexp/no-dupe-disjunctions, regexp/no-useless-non-capturing-group
let rxOneValueWithSeparator = /("((?:(?:[^"]*?)(?:"")?)*)"|([^,;\t\n]*))([,;\t\n]|\r\n)/g
if (opt.separator)
rxOneValueWithSeparator = new RegExp(rxOneValueWithSeparator.source.replaceAll(',;\\t', escapeRegExp(opt.separator)), rxOneValueWithSeparator.flags)
rxOneValueWithSeparator = new RegExp(rxOneValueWithSeparator.source.replace(/',;\\t/g, escapeRegExp(opt.separator)), rxOneValueWithSeparator.flags)

const lines: any[][] = []
let row: any[] = []
let m: any
const text = `${raw.replaceAll('\r\n', '\n').trim()}\n`
const text = `${raw.replace(/\r\n/g, '\n').trim()}\n`

// eslint-disable-next-line no-cond-assign
while (m = rxOneValueWithSeparator.exec(text)) {
let value = m[2] ?? m[3] ?? ''
value = value.replaceAll('""', '"')
value = value.replace(/""/g, '"')
row.push(value)
if (m[4] === '\n') {
lines.push(row)
Expand Down
8 changes: 4 additions & 4 deletions src/common/data/basex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,10 @@ export function encodeBase32(bin: BinInput, padding = -1) {
export function decodeBase32(s: string, padding = -1) {
return useBase(32).decode(s
.toLocaleLowerCase()
.replaceAll('l', '1')
.replaceAll('s', '5')
.replaceAll('o', '0')
.replaceAll('i', '1'), padding)
.replace(/l/g, '1')
.replace(/s/g, '5')
.replace(/o/g, '0')
.replace(/i/g, '1'), padding)
}

export function encodeBase16(bin: BinInput, padding = -1) {
Expand Down
8 changes: 4 additions & 4 deletions src/common/data/bin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,24 +117,24 @@ export function toBase64(bin: BinInput, stripPadding = false): string {
sb = btoa(s)
}
if (stripPadding)
return sb.replaceAll('=', '')
return sb.replace(/\=/g, '')
return sb
}

/** Converts `+` -> `-` and `/` -> `_`. Always strips `=` */
export function toBase64Url(bin: BinInput): string {
const bytes = toUint8Array(bin)
if (typeof Buffer !== 'undefined')
return Buffer.from(bytes).toString('base64url').replaceAll('=', '')
return Buffer.from(bytes).toString('base64url').replace(/\=/g, '')
let s = ''
for (let i = 0; i < bytes.byteLength; i++)
s += String.fromCharCode(bytes[i])
return btoa(s).replaceAll('+', '-').replaceAll('/', '_').replaceAll('=', '')
return btoa(s).replace(/\+/g, '-').replace(/\//g, '_').replace(/\=/g, '')
}

/** Also parses toBase64Url encoded strings. */
export function fromBase64(s: string): Uint8Array {
s = s.replaceAll('-', '+').replaceAll('_', '/')
s = s.replace(/\-/g, '+').replace(/\_/g, '/')
if (typeof Buffer !== 'undefined') {
const buf = Buffer.from(s, 'base64')
return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength)
Expand Down
6 changes: 3 additions & 3 deletions src/common/data/object.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export function objectFilter<T = any>(
): Partial<T> {
if (!isObject(obj))
return {}
return Object.fromEntries(Object.entries(obj).filter(([k,v]) => fn(k,v))) as any
return Object.fromEntries(Object.entries(obj).filter(([k, v]) => fn(k, v))) as any
}

/** Merge right into left object. If dispose is defined, it will be combined. Left can be a complex object i.e. a insantiated class. */
Expand Down Expand Up @@ -136,7 +136,7 @@ export function objectPlain(obj: any, opt?: {
name: obj.name,
message: obj.message,
stack: errorTrace ? obj.stack : undefined,
cause: obj.cause ? String(obj.cause) : undefined,
cause: (obj as any).cause ? String((obj as any).cause) : undefined,
}
}
// return `${obj.name || 'Error'}: ${obj.message}${errorTrace ? `\n${obj.stack}` : ''}`
Expand All @@ -160,7 +160,7 @@ export function objectPlain(obj: any, opt?: {
// __code: obj.toString ? obj.toString() : undefined,
}
for (const k in obj) {
if (Object.hasOwn(obj, k) && isPrimitive(obj[k]))
if (obj && obj.hasOwnProperty(k) && isPrimitive(obj[k]))
nobj[k] = obj[k]
}
return nobj
Expand Down
2 changes: 1 addition & 1 deletion src/common/uuid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export function uuidEncodeV4(bytes: Uint8Array): string {
}

export function uuidDecodeV4(uuid: string): Uint8Array {
return fromHex(uuid.replaceAll('-', ''))
return fromHex(uuid.replace(/-/g, ''))
}

// Sortable UID
Expand Down
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"target": "ES2020",
"jsx": "preserve",
"lib": [
"ES2022",
"ES2020",
"ESNext.Disposable",
"DOM",
"DOM.Iterable"
Expand Down
2 changes: 1 addition & 1 deletion vitest.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/// <reference types="vitest" />

import type { UserConfig } from 'vitest'
import type { UserConfig } from 'vitest/node'
import { resolve } from 'node:path'
import process from 'node:process'
import { defineConfig } from 'vite'
Expand Down

0 comments on commit 396a969

Please sign in to comment.