static JSValue js_bs_put_val(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv, u32 mode)
{
	s64 val;
	GET_JSBS
	if (!bs || !argc) return GF_JS_EXCEPTION(ctx);
	if (JS_ToInt64(ctx, &val, argv[0])) return GF_JS_EXCEPTION(ctx);
	switch (mode) {
	case 0: gf_bs_write_u8(bs, (u32) val); break;
	case 1: gf_bs_write_u8(bs, (u32) val); break;
	case 2: gf_bs_write_u16(bs, (u32) val); break;
	case 3: gf_bs_write_u16_le(bs, (u32) val); break;
	case 4: gf_bs_write_u16(bs, (u32) val); break;
	case 5: gf_bs_write_u24(bs, (u32) val); break;
	case 6: gf_bs_write_u32(bs, (u32) val); break;
	case 7: gf_bs_write_u32_le(bs, (u32) val); break;
	case 8: gf_bs_write_u32(bs, (u32) val); break;
	case 9: gf_bs_write_u64(bs, (u64) val); break;
	case 10: gf_bs_write_u64_le(bs, (u64) val); break;
	case 11: gf_bs_write_u64(bs, (u64) val); break;
	}
	return JS_UNDEFINED;
}
static JSValue js_bs_put_val(JSContext *ctx, JSValueConst this_val, int argc, JSValueConst *argv, u32 mode)
{
	s64 val;
	GET_JSBS
	if (!bs || !argc) return GF_JS_EXCEPTION(ctx);
	if (JS_ToInt64(ctx, &val, argv[0])) return GF_JS_EXCEPTION(ctx);
	switch (mode) {
	case 0: gf_bs_write_u8(bs, (u32) val); break;
	case 1: gf_bs_write_u8(bs, (u32) val); break;
	case 2: gf_bs_write_u16(bs, (u32) val); break;
	case 3: gf_bs_write_u16_le(bs, (u32) val); break;
	case 4: gf_bs_write_u16(bs, (u32) val); break;
	case 5: gf_bs_write_u24(bs, (u32) val); break;
	case 6: gf_bs_write_u32(bs, (u32) val); break;
	case 7: gf_bs_write_u32_le(bs, (u32) val); break;
	case 8: gf_bs_write_u32(bs, (u32) val); break;
	case 9: gf_bs_write_u64(bs, (u64) val); break;
	case 10: gf_bs_write_u64_le(bs, (u64) val); break;
	case 11: gf_bs_write_u64(bs, (u64) val); break;
	}
	return JS_UNDEFINED;
}