const std = @import("std");
const assert = std.debug.assert;
/// An intrusive first in/first out linked list.
/// The element type T must have a field called "next" of type ?*T
pub fn FIFO(comptime T: type) type {
return struct {
const Self = @This();
in: ?*T = null,
out: ?*T = null,
pub fn push(self: *Self, elem: *T) void {
assert(elem.next == null);
if (self.in) |in| {
in.next = elem;
self.in = elem;
} else {
assert(self.out == null);
self.in = elem;
self.out = elem;
}
}
pub fn pop(self: *Self) ?*T {
const ret = self.out orelse return null;
self.out = ret.next;
ret.next = null;
if (self.in == ret) self.in = null;
return ret;
}
pub fn peek(self: Self) ?*T {
return self.out;
}
/// Remove an element from the FIFO. Asserts that the element is
/// in the FIFO. This operation is O(N), if this is done often you
/// probably want a different data structure.
pub fn remove(self: *Self, to_remove: *T) void {
if (to_remove == self.out) {
_ = self.pop();
return;
}
var it = self.out;
while (it) |elem| : (it = elem.next) {
if (to_remove == elem.next) {
if (to_remove == self.in) self.in = elem;
elem.next = to_remove.next;
to_remove.next = null;
break;
}
} else unreachable;
}
};
}
test "push/pop/peek/remove" {
const testing = @import("std").testing;
const Foo = struct { next: ?*@This() = null };
var one: Foo = .{};
var two: Foo = .{};
var three: Foo = .{};
var fifo: FIFO(Foo) = .{};
fifo.push(&one);
try testing.expectEqual(@as(?*Foo, &one), fifo.peek());
fifo.push(&two);
fifo.push(&three);
try testing.expectEqual(@as(?*Foo, &one), fifo.peek());
fifo.remove(&one);
try testing.expectEqual(@as(?*Foo, &two), fifo.pop());
try testing.expectEqual(@as(?*Foo, &three), fifo.pop());
try testing.expectEqual(@as(?*Foo, null), fifo.pop());
fifo.push(&one);
fifo.push(&two);
fifo.push(&three);
fifo.remove(&two);
try testing.expectEqual(@as(?*Foo, &one), fifo.pop());
try testing.expectEqual(@as(?*Foo, &three), fifo.pop());
try testing.expectEqual(@as(?*Foo, null), fifo.pop());
fifo.push(&one);
fifo.push(&two);
fifo.push(&three);
fifo.remove(&three);
try testing.expectEqual(@as(?*Foo, &one), fifo.pop());
try testing.expectEqual(@as(?*Foo, &two), fifo.pop());
try testing.expectEqual(@as(?*Foo, null), fifo.pop());
fifo.push(&one);
fifo.push(&two);
fifo.remove(&two);
fifo.push(&three);
try testing.expectEqual(@as(?*Foo, &one), fifo.pop());
try testing.expectEqual(@as(?*Foo, &three), fifo.pop());
try testing.expectEqual(@as(?*Foo, null), fifo.pop());
}
x/event-emitter-async-iter'>derrick/fix/event-emitter-async-iter
derrick/fix/event-emitter-emit-throw-native
derrick/fix/http-lowercase-headers
derrick/fix/node-tests
derrick/test/add-ed25519-tests
detect-libc
doc/0.8
dylan/callback-fulfilled-after-rejection
dylan/change-pathname-assert
dylan/cli-fixes
dylan/encoding-fix
dylan/fix-bundling-lodash-es-is-buffer
dylan/fix-error-inlining
dylan/fix-module-field-in-exports
dylan/github-api-option
dylan/github-dependencies
dylan/import-file-path
dylan/non-enumerable-export-values
dylan/resolve-rope-in-string
dylan/set-exit-code
dylan/source-map-names-property
eventstream
feat/ecosystem
feat/npm
fix
fix-prepare-stack-trace
fix-websocket-upgrade
fs-watch-file
got
guides-3
improve-docker
insensitive-pkg-names
integration-tests
jarred/5859
jarred/actions
jarred/add-git
jarred/analytics
jarred/arenas
jarred/ast
jarred/ast-again
jarred/async_bio
jarred/bench
jarred/brotli
jarred/bump-uws
jarred/bundle-workspace-packages
jarred/bunfig
jarred/callable
jarred/canvas
jarred/ci-check
jarred/cjs2
jarred/cleanup-error
jarred/clipboard-objc
jarred/direct
jarred/dump
jarred/edgecase
jarred/esbuild-plugin-api
jarred/escapeHTML
jarred/esm-conditions
jarred/experiment-bsp
jarred/export-star-flat
jarred/exports-map
jarred/faster-error-capturestacktrace
jarred/faster-ordered-properties
jarred/fastmalloc
jarred/fetch-experiment
jarred/fetchheaders
jarred/fix-blob-slice-test
jarred/fix-bunbun-on-wsl
jarred/fix-crash
jarred/fix-http-compression
jarred/fix-issue-with-tsconfig-run
jarred/fix-proxy-regression
jarred/fixes-3129
jarred/gen
jarred/htmlrewriter
jarred/improve-testing
jarred/inquirer
jarred/isolation
jarred/jsc
jarred/land
jarred/landing
jarred/linux
jarred/live-bindings
jarred/make-strings-better
jarred/mdx-thrwawy
jarred/move
jarred/napi
jarred/new-bund
jarred/new-bund-ressurected-branch
jarred/new-http
jarred/no-more-npm
jarred/package-mapper
jarred/pg
jarred/port
jarred/possibly-2732
jarred/postgresql
jarred/precompile-linux-dependencies
jarred/prepare-for-libuv
jarred/profiled-call
jarred/read-tsconfig-jsx
jarred/redo-evaluation-order
jarred/redo-zigstring-for-utf16
jarred/relay
jarred/rename
jarred/repl
jarred/request-finalizer
jarred/rewrite-router
jarred/run
jarred/simdjson
jarred/simplify
jarred/some-fixes-for-eventsource
jarred/standalone-repro1
jarred/start
jarred/strong
jarred/subprocess
jarred/support-tee
jarred/tcc
jarred/throw-if
jarred/update-install-stuff
jarred/update-zig1
jarred/upgrade-zig-2
jarred/uws
jarred/webkit-upgrade-may-17
jarred/wip-more-reliable
jarred/workers
jarred/zlib
jarred/zls
lithdew/picohttp-mimalloc
main
move-templates
nestjs-guide
next-cleanup
origin/main
plugin/plugindata
plugin/resolvedir
postinstall_3
repl
request-body-stream
reserve-commands
revert-5167-dylan/decode-regex-if-needed
rfc/bun-bundler-api
rfc/bunfig-overhaul
save-in-update
sdl
test/action
types/mock
types/readable-stream-default
types/tty
u/vjpr/zig-0.10
xHyroM/types/expose-Bun-Env
Unnamed repository; edit this file 'description' to name the repository.
Age Commit message (Collapse ) Author Files Lines
* Fix `make jsc` on Linux
Previously, it failed with `/usr/bin/bash: Line 3: -DUSE_BUN_JSC_ADDITIONS=ON: Command not found`.
* Update Makefile
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
---------
Co-authored-by: Jarred Sumner <jarred@jarredsumner.com>
The sqlite3 logic to dynamically load extensions can be disabled to save space,
which macos does by default.
sqlite3 provides a api to check for these compile time settings at runtime,
we can use that to throw a js error rather then crashing.
It is worth noting though that the api to check for these settings at runtime
itself can be disabled through SQLITE_OMIT_COMPILEOPTION_DIAGS but this seams
to be a edge case.
This make it as the same default depth in Node.
Source: https://github.com/nodejs/node/blob/480ab8c3a40451d5ea459dd35b4039679b26e195/doc/api/console.md?plain=1#L285
WTFString here
* fix(fetch): fix redirect in relative path location.
* fix utf-8 encoding
* use server.reload
* check buf size
* add RedirectURLTooLong test
sudo is required to run pacman if not root user
* test
* gadsgsagdsa
* add better err msg
* r
* oops
* ok
* fix size limit
* 63
* throw error
* ffi.test.js
* add macos tests
* oops
* fix(encoding): export `getIgnoreBOM`
* feat(encoding): support ignoreBOM
* fix(encoding): not replace BOM to 0xFFFD
* chore: use strict equal
* feat(node:dns): implement dns.lookupService
Close: #4347
* fix flags
* add `getSockaddr`
* fix sockaddr size
* flaky test
* implement console._stdout
* nonenum
* Improve types for each
* more
* remove
* [bun install] Add `-E` as alias of `--exact`
* Add test for -E flag
* feat: switch disableTelemetry to bunfig
* feat: zig fmt
* revert: the env variable and invert the logic of telemetry
---------
Co-authored-by: MrPalixir <73360179+MrPalixir@users.noreply.github.com>
Fix: https://github.com/napi-rs/napi-rs/blob/main/examples/napi/__tests__/test.framework.js#L16-L19
* Fix bugs
* Fix bugs
* Revert "Fix bugs"
This reverts commit 608639eb2214fdf4310477051ce47d20702b5dd0.
* some progess
* needs more tests
* make tests easier to debug
* get metadata for constructor arg decorators
* fix some things
* merge `emitDecoratorMetadata` option
* remove `^`
* bundler tests and get option from tsconfig earlier
* remove spaces
* fix tests
* Always call `Error.prepareStackTrace`
* Support node:vm
* Remove this
* Handle more cases
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
Fixes #5800
* Fix path used in bunx
* Add test
* Use a different package
---------
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>
The URL to download the manifest for Artifact Registry in Google
is larger than 4092 bytes.
cf. issue #4748
Co-authored-by: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com>