MyGit

bun-v0.0.71

oven-sh/bun

版本发布时间: 2022-02-25 21:49:39

oven-sh/bun最新发布版本:bun-v1.1.38(2024-11-29 19:55:48)

To upgrade:

bun upgrade

Having trouble?
# Try this
curl https://bun.sh/install | bash

Please let me know though if it doesn't work and you're on bun v0.0.69. bun v0.0.61 - v0.0.68 had issues with the HTTP client

Highlights:

# Install a package globally with bun install
> bun install -g typescript

# "bun i" is shorthand for bun install
> bun i -g typescript

# It symlinks into your $BUN_INSTALL/bin folder
> which tsc
/Users/jarred/.bun/bin/tsc

# print the path of the global bin
> bun pm -g bin 
/Users/jarred/.bun/bin

Lowlights:

"Copy as markdown" button for error messages

Before this release, bun dev did not support displaying runtime errors. It only showed errors for build/ssr 🙈

Use macros like regular JavaScript

Now you can move code from runtime to build-time by writing ordinary javascript.

Input:

// This line is removed at build time
import {weatherIn} from 'macro:./weather'

// This function call is replaced with the value of `weatherIn(94609)` at build-time
const {current_condition: [{temp_F: degrees}]} = weatherIn(94609);

export default `It is ${degrees} in Oakland, California`

weather.js:

export async function weatherIn(call) {
    const location = call.arguments[0];
    return fetch(`https://wttr.in/${location.toString()}?format=j1`)
} 

Output:

const {
  current_condition: [{ temp_F: degrees }]
} = {
  current_condition: [
    {
      temp_F: "42"
    }
  ]
};
// once bun gets a minifier, this line would be all that remains
export default `It is ${degrees} in Oakland, California`;
Normally, this 48 KB of JSON would be fetched client-side
{
    "current_condition": [
        {
            "FeelsLikeC": "4",
            "FeelsLikeF": "39",
            "cloudcover": "100",
            "humidity": "79",
            "localObsDateTime": "2022-02-25 03:18 AM",
            "observation_time": "11:18 AM",
            "precipInches": "0.0",
            "precipMM": "0.0",
            "pressure": "1026",
            "pressureInches": "30",
            "temp_C": "4",
            "temp_F": "40",
            "uvIndex": "1",
            "visibility": "16",
            "visibilityMiles": "9",
            "weatherCode": "122",
            "weatherDesc": [
                {
                    "value": "Overcast"
                }
            ],
            "weatherIconUrl": [
                {
                    "value": ""
                }
            ],
            "winddir16Point": "ENE",
            "winddirDegree": "70",
            "windspeedKmph": "7",
            "windspeedMiles": "4"
        }
    ],
    "nearest_area": [
        {
            "areaName": [
                {
                    "value": "Emeryville"
                }
            ],
            "country": [
                {
                    "value": "United States of America"
                }
            ],
            "latitude": "37.831",
            "longitude": "-122.284",
            "population": "0",
            "region": [
                {
                    "value": "California"
                }
            ],
            "weatherUrl": [
                {
                    "value": ""
                }
            ]
        }
    ],
    "request": [
        {
            "query": "Lat 37.83 and Lon -122.26",
            "type": "LatLon"
        }
    ],
    "weather": [
        {
            "astronomy": [
                {
                    "moon_illumination": "24",
                    "moon_phase": "Last Quarter",
                    "moonrise": "03:03 AM",
                    "moonset": "12:25 PM",
                    "sunrise": "06:46 AM",
                    "sunset": "05:59 PM"
                }
            ],
            "avgtempC": "10",
            "avgtempF": "49",
            "date": "2022-02-25",
            "hourly": [
                {
                    "DewPointC": "2",
                    "DewPointF": "36",
                    "FeelsLikeC": "5",
                    "FeelsLikeF": "42",
                    "HeatIndexC": "7",
                    "HeatIndexF": "44",
                    "WindChillC": "5",
                    "WindChillF": "42",
                    "WindGustKmph": "11",
                    "WindGustMiles": "7",
                    "chanceoffog": "0",
                    "chanceoffrost": "0",
                    "chanceofhightemp": "0",
                    "chanceofovercast": "0",
                    "chanceofrain": "0",
                    "chanceofremdry": "82",
                    "chanceofsnow": "0",
                    "chanceofsunshine": "88",
                    "chanceofthunder": "0",
                    "chanceofwindy": "0",
                    "cloudcover": "4",
                    "humidity": "75",
                    "precipInches": "0.0",
                    "precipMM": "0.0",
                    "pressure": "1025",
                    "pressureInches": "30",
                    "tempC": "7",
                    "tempF": "44",
                    "time": "0",
                    "uvIndex": "1",
                    "visibility": "10",
                    "visibilityMiles": "6",
                    "weatherCode": "113",
                    "weatherDesc": [
                        {
                            "value": "Clear"
                        }
                    ],
                    "weatherIconUrl": [
                        {
                            "value": ""
                        }
                    ],
                    "winddir16Point": "WNW",
                    "winddirDegree": "300",
                    "windspeedKmph": "6",
                    "windspeedMiles": "4"
                },
                {
                    "DewPointC": "2",
                    "DewPointF": "35",
                    "FeelsLikeC": "6",
                    "FeelsLikeF": "42",
                    "HeatIndexC": "6",
                    "HeatIndexF": "42",
                    "WindChillC": "6",
                    "WindChillF": "42",
                    "WindGustKmph": "3",
                    "WindGustMiles": "2",
                    "chanceoffog": "0",
                    "chanceoffrost": "0",
                    "chanceofhightemp": "0",
                    "chanceofovercast": "0",
                    "chanceofrain": "0",
                    "chanceofremdry": "81",
                    "chanceofsnow": "0",
                    "chanceofsunshine": "93",
                    "chanceofthunder": "0",
                    "chanceofwindy": "0",
                    "cloudcover": "0",
                    "humidity": "78",
                    "precipInches": "0.0",
                    "precipMM": "0.0",
                    "pressure": "1026",
                    "pressureInches": "30",
                    "tempC": "6",
                    "tempF": "42",
                    "time": "300",
                    "uvIndex": "1",
                    "visibility": "10",
                    "visibilityMiles": "6",
                    "weatherCode": "113",
                    "weatherDesc": [
                        {
                            "value": "Clear"
                        }
                    ],
                    "weatherIconUrl": [
                        {
                            "value": ""
                        }
                    ],
                    "winddir16Point": "N",
                    "winddirDegree": "360",
                    "windspeedKmph": "2",
                    "windspeedMiles": "1"
                },
                {
                    "DewPointC": "1",
                    "DewPointF": "34",
                    "FeelsLikeC": "4",
                    "FeelsLikeF": "39",
                    "HeatIndexC": "5",
                    "HeatIndexF": "40",
                    "WindChillC": "4",
                    "WindChillF": "39",
                    "WindGustKmph": "9",
                    "WindGustMiles": "5",
                    "chanceoffog": "0",
                    "chanceoffrost": "0",
                    "chanceofhightemp": "0",
                    "chanceofovercast": "0",
                    "chanceofrain": "0",
                    "chanceofremdry": "91",
                    "chanceofsnow": "0",
                    "chanceofsunshine": "94",
                    "chanceofthunder": "0",
                    "chanceofwindy": "0",
                    "cloudcover": "0",
                    "humidity": "78",
                    "precipInches": "0.0",
                    "precipMM": "0.0",
                    "pressure": "1025",
                    "pressureInches": "30",
                    "tempC": "5",
                    "tempF": "40",
                    "time": "600",
                    "uvIndex": "1",
                    "visibility": "10",
                    "visibilityMiles": "6",
                    "weatherCode": "113",
                    "weatherDesc": [
                        {
                            "value": "Clear"
                        }
                    ],
                    "weatherIconUrl": [
                        {
                            "value": ""
                        }
                    ],
                    "winddir16Point": "ENE",
                    "winddirDegree": "72",
                    "windspeedKmph": "5",
                    "windspeedMiles": "3"
                },
                {
                    "DewPointC": "-1",
                    "DewPointF": "31",
                    "FeelsLikeC": "5",
                    "FeelsLikeF": "41",
                    "HeatIndexC": "6",
                    "HeatIndexF": "42",
                    "WindChillC": "5",
                    "WindChillF": "41",
                    "WindGustKmph": "7",
                    "WindGustMiles": "4",
                    "chanceoffog": "0",
                    "chanceoffrost": "0",
                    "chanceofhightemp": "0",
                    "chanceofovercast": "0",
                    "chanceofrain": "0",
                    "chanceofremdry": "89",
                    "chanceofsnow": "0",
                    "chanceofsunshine": "87",
                    "chanceofthunder": "0",
                    "chanceofwindy": "0",
                    "cloudcover": "0",
                    "humidity": "64",
                    "precipInches": "0.0",
                    "precipMM": "0.0",
                    "pressure": "1026",
                    "pressureInches": "30",
                    "tempC": "6",
                    "tempF": "42",
                    "time": "900",
                    "uvIndex": "3",
                    "visibility": "10",
                    "visibilityMiles": "6",
                    "weatherCode": "113",
                    "weatherDesc": [
                        {
                            "value": "Sunny"
                        }
                    ],
                    "weatherIconUrl": [
                        {
                            "value": ""
                        }
                    ],
                    "winddir16Point": "ENE",
                    "winddirDegree": "72",
                    "windspeedKmph": "5",
                    "windspeedMiles": "3"
                },
                {
                    "DewPointC": "0",
                    "DewPointF": "32",
                    "FeelsLikeC": "13",
                    "FeelsLikeF": "56",
                    "HeatIndexC": "13",
                    "HeatIndexF": "56",
                    "WindChillC": "13",
                    "WindChillF": "56",
                    "WindGustKmph": "8",
                    "WindGustMiles": "5",
                    "chanceoffog": "0",
                    "chanceoffrost": "0",
                    "chanceofhightemp": "0",
                    "chanceofovercast": "0",
                    "chanceofrain": "0",
                    "chanceofremdry": "80",
                    "chanceofsnow": "0",
                    "chanceofsunshine": "85",
                    "chanceofthunder": "0",
                    "chanceofwindy": "0",
                    "cloudcover": "0",
                    "humidity": "40",
                    "precipInches": "0.0",
                    "precipMM": "0.0",
                    "pressure": "1026",
                    "pressureInches": "30",
                    "tempC": "13",
                    "tempF": "56",
                    "time": "1200",
                    "uvIndex": "4",
                    "visibility": "10",
                    "visibilityMiles": "6",
                    "weatherCode": "113",
                    "weatherDesc": [
                        {
                            "value": "Sunny"
                        }
                    ],
                    "weatherIconUrl": [
                        {
                            "value": ""
                        }
                    ],
                    "winddir16Point": "ENE",
                    "winddirDegree": "70",
                    "windspeedKmph": "7",
                    "windspeedMiles": "4"
                },
                {
                    "DewPointC": "1",
                    "DewPointF": "33",
                    "FeelsLikeC": "17",
                    "FeelsLikeF": "62",
                    "HeatIndexC": "17",
                    "HeatIndexF": "62",
                    "WindChillC": "17",
                    "WindChillF": "62",
                    "WindGustKmph": "8",
                    "WindGustMiles": "5",
                    "chanceoffog": "0",
                    "chanceoffrost": "0",
                    "chanceofhightemp": "0",
                    "chanceofovercast": "0",
                    "chanceofrain": "0",
                    "chanceofremdry": "89",
                    "chanceofsnow": "0",
                    "chanceofsunshine": "88",
                    "chanceofthunder": "0",
                    "chanceofwindy": "0",
                    "cloudcover": "0",
                    "humidity": "34",
                    "precipInches": "0.0",
                    "precipMM": "0.0",
                    "pressure": "1025",
                    "pressureInches": "30",
                    "tempC": "17",
                    "tempF": "62",
                    "time": "1500",
                    "uvIndex": "5",
                    "visibility": "10",
                    "visibilityMiles": "6",
                    "weatherCode": "113",
                    "weatherDesc": [
                        {
                            "value": "Sunny"
                        }
                    ],
                    "weatherIconUrl": [
                        {
                            "value": ""
                        }
                    ],
                    "winddir16Point": "NNW",
                    "winddirDegree": "330",
                    "windspeedKmph": "7",
                    "windspeedMiles": "4"
                },
                {
                    "DewPointC": "2",
                    "DewPointF": "36",
                    "FeelsLikeC": "16",
                    "FeelsLikeF": "61",
                    "HeatIndexC": "16",
                    "HeatIndexF": "61",
                    "WindChillC": "16",
                    "WindChillF": "61",
                    "WindGustKmph": "9",
                    "WindGustMiles": "6",
                    "chanceoffog": "0",
                    "chanceoffrost": "0",
                    "chanceofhightemp": "0",
                    "chanceofovercast": "0",
                    "chanceofrain": "0",
                    "chanceofremdry": "80",
                    "chanceofsnow": "0",
                    "chanceofsunshine": "93",
                    "chanceofthunder": "0",
                    "chanceofwindy": "0",
                    "cloudcover": "0",
                    "humidity": "39",
                    "precipInches": "0.0",
                    "precipMM": "0.0",
                    "pressure": "1024",
                    "pressureInches": "30",
                    "tempC": "16",
                    "tempF": "61",
                    "time": "1800",
                    "uvIndex": "1",
                    "visibility": "10",
                    "visibilityMiles": "6",
                    "weatherCode": "113",
                    "weatherDesc": [
                        {
                            "value": "Clear"
                        }
                    ],
                    "weatherIconUrl": [
                        {
                            "value": ""
                        }
                    ],
                    "winddir16Point": "NW",
                    "winddirDegree": "307",
                    "windspeedKmph": "8",
                    "windspeedMiles": "5"
                },
                {
                    "DewPointC": "2",
                    "DewPointF": "35",
                    "FeelsLikeC": "8",
                    "FeelsLikeF": "47",
                    "HeatIndexC": "9",
                    "HeatIndexF": "48",
                    "WindChillC": "8",
                    "WindChillF": "47",
                    "WindGustKmph": "12",
                    "WindGustMiles": "7",
                    "chanceoffog": "0",
                    "chanceoffrost": "0",
                    "chanceofhightemp": "0",
                    "chanceofovercast": "0",
                    "chanceofrain": "0",
                    "chanceofremdry": "87",
                    "chanceofsnow": "0",
                    "chanceofsunshine": "85",
                    "chanceofthunder": "0",
                    "chanceofwindy": "0",
                    "cloudcover": "0",
                    "humidity": "61",
                    "precipInches": "0.0",
                    "precipMM": "0.0",
                    "pressure": "1025",
                    "pressureInches": "30",
                    "tempC": "9",
                    "tempF": "48",
                    "time": "2100",
                    "uvIndex": "1",
                    "visibility": "10",
                    "visibilityMiles": "6",
                    "weatherCode": "113",
                    "weatherDesc": [
                        {
                            "value": "Clear"
                        }
                    ],
                    "weatherIconUrl": [
                        {
                            "value": ""
                        }
                    ],
                    "winddir16Point": "NW",
                    "winddirDegree": "305",
                    "windspeedKmph": "6",
                    "windspeedMiles": "4"
                }
            ],
            "maxtempC": "17",
            "maxtempF": "63",
            "mintempC": "4",
            "mintempF": "39",
            "sunHour": "11.0",
            "totalSnow_cm": "0.0",
            "uvIndex": "4"
        },
        {
            "astronomy": [
                {
                    "moon_illumination": "17",
                    "moon_phase": "Waning Crescent",
                    "moonrise": "04:08 AM",
                    "moonset": "01:29 PM",
                    "sunrise": "06:44 AM",
                    "sunset": "06:00 PM"
                }
            ],
            "avgtempC": "10",
            "avgtempF": "51",
            "date": "2022-02-26",
            "hourly": [
                {
                    "DewPointC": "2",
                    "DewPointF": "35",
                    "FeelsLikeC": "7",
                    "FeelsLikeF": "45",
                    "HeatIndexC": "8",
                    "HeatIndexF": "46",
                    "WindChillC": "7",
                    "WindChillF": "45",
                    "WindGustKmph": "8",
                    "WindGustMiles": "5",
                    "chanceoffog": "0",
                    "chanceoffrost": "0",
                    "chanceofhightemp": "0",
                    "chanceofovercast": "0",
                    "chanceofrain": "0",
                    "chanceofremdry": "83",
                    "chanceofsnow": "0",
                    "chanceofsunshine": "91",
                    "chanceofthunder": "0",
                    "chanceofwindy": "0",
                    "cloudcover": "0",
                    "humidity": "67",
                    "precipInches": "0.0",
                    "precipMM": "0.0",
                    "pressure": "1026",
                    "pressureInches": "30",
                    "tempC": "8",
                    "tempF": "46",
                    "time": "0",
                    "uvIndex": "1",
                    "visibility": "10",
                    "visibilityMiles": "6",
                    "weatherCode": "113",
                    "weatherDesc": [
                        {
                            "value": "Clear"
                        }
                    ],
                    "weatherIconUrl": [
                        {
                            "value": ""
                        }
                    ],
                    "winddir16Point": "N",
                    "winddirDegree": "353",
                    "windspeedKmph": "4",
                    "windspeedMiles": "3"
                },
                {
                    "DewPointC": "0",
                    "DewPointF": "33",
                    "FeelsLikeC": "7",
                    "FeelsLikeF": "45",
                    "HeatIndexC": "7",
                    "HeatIndexF": "45",
                    "WindChillC": "7",
                    "WindChillF": "45",
                    "WindGustKmph": "7",
                    "WindGustMiles": "4",
                    "chanceoffog": "0",
                    "chanceoffrost": "0",
                    "chanceofhightemp": "0",
                    "chanceofovercast": "0",
                    "chanceofrain": "0",
                    "chanceofremdry": "91",
                    "chanceofsnow": "0",
                    "chanceofsunshine": "94",
                    "chanceofthunder": "0",
                    "chanceofwindy": "0",
                    "cloudcover": "12",
                    "humidity": "62",
                    "precipInches": "0.0",
                    "precipMM": "0.0",
                    "pressure": "1025",
                    "pressureInches": "30",
                    "tempC": "7",
                    "tempF": "45",
                    "time": "300",
                    "uvIndex": "1",
                    "visibility": "10",
                    "visibilityMiles": "6",
                    "weatherCode": "113",
                    "weatherDesc": [
                        {
                            "value": "Clear"
                        }
                    ],
                    "weatherIconUrl": [
                        {
                            "value": ""
                        }
                    ],
                    "winddir16Point": "E",
                    "winddirDegree": "90",
                    "windspeedKmph": "4",
                    "windspeedMiles": "2"
                },
                {
                    "DewPointC": "-1",
                    "DewPointF": "31",
                    "FeelsLikeC": "6",
                    "FeelsLikeF": "42",
                    "HeatIndexC": "7",
                    "HeatIndexF": "44",
                    "WindChillC": "6",
                    "WindChillF": "42",
                    "WindGustKmph": "11",
                    "WindGustMiles": "7",
                    "chanceoffog": "0",
                    "chanceoffrost": "0",
                    "chanceofhightemp": "0",
                    "chanceofovercast": "0",
                    "chanceofrain": "0",
                    "chanceofremdry": "81",
                    "chanceofsnow": "0",
                    "chanceofsunshine": "92",
                    "chanceofthunder": "0",
                    "chanceofwindy": "0",
                    "cloudcover": "9",
                    "humidity": "61",
                    "precipInches": "0.0",
                    "precipMM": "0.0",
                    "pressure": "1026",
                    "pressureInches": "30",
                    "tempC": "7",
                    "tempF": "44",
                    "time": "600",
                    "uvIndex": "1",
                    "visibility": "10",
                    "visibilityMiles": "6",
                    "weatherCode": "113",
                    "weatherDesc": [
                        {
                            "value": "Clear"
                        }
                    ],
                    "weatherIconUrl": [
                        {
                            "value": ""
                        }
                    ],
                    "winddir16Point": "ENE",
                    "winddirDegree": "66",
                    "windspeedKmph": "6",
                    "windspeedMiles": "4"
                },
                {
                    "DewPointC": "-1",
                    "DewPointF": "31",
                    "FeelsLikeC": "6",
                    "FeelsLikeF": "43",
                    "HeatIndexC": "7",
                    "HeatIndexF": "45",
                    "WindChillC": "6",
                    "WindChillF": "43",
                    "WindGustKmph": "9",
                    "WindGustMiles": "5",
                    "chanceoffog": "0",
                    "chanceoffrost": "0",
                    "chanceofhightemp": "0",
                    "chanceofovercast": "0",
                    "chanceofrain": "0",
                    "chanceofremdry": "83",
                    "chanceofsnow": "0",
                    "chanceofsunshine": "92",
                    "chanceofthunder": "0",
                    "chanceofwindy": "0",
                    "cloudcover": "4",
                    "humidity": "57",
                    "precipInches": "0.0",
                    "precipMM": "0.0",
                    "pressure": "1027",
                    "pressureInches": "30",
                    "tempC": "7",
                    "tempF": "45",
                    "time": "900",
                    "uvIndex": "3",
                    "visibility": "10",
                    "visibilityMiles": "6",
                    "weatherCode": "113",
                    "weatherDesc": [
                        {
                            "value": "Sunny"
                        }
                    ],
                    "weatherIconUrl": [
                        {
                            "value": ""
                        }
                    ],
                    "winddir16Point": "ENE",
                    "winddirDegree": "71",
                    "windspeedKmph": "6",
                    "windspeedMiles": "4"
                },
                {
                    "DewPointC": "1",
                    "DewPointF": "33",
                    "FeelsLikeC": "14",
                    "FeelsLikeF": "57",
                    "HeatIndexC": "13",
                    "HeatIndexF": "56",
                    "WindChillC": "14",
                    "WindChillF": "57",
                    "WindGustKmph": "4",
                    "WindGustMiles": "2",
                    "chanceoffog": "0",
                    "chanceoffrost": "0",
                    "chanceofhightemp": "0",
                    "chanceofovercast": "0",
                    "chanceofrain": "0",
                    "chanceofremdry": "83",
                    "chanceofsnow": "0",
                    "chanceofsunshine": "89",
                    "chanceofthunder": "0",
                    "chanceofwindy": "0",
                    "cloudcover": "7",
                    "humidity": "43",
                    "precipInches": "0.0",
                    "precipMM": "0.0",
                    "pressure": "1027",
                    "pressureInches": "30",
                    "tempC": "13",
                    "tempF": "56",
                    "time": "1200",
                    "uvIndex": "4",
                    "visibility": "10",
                    "visibilityMiles": "6",
                    "weatherCode": "113",
                    "weatherDesc": [
                        {
                            "value": "Sunny"
                        }
                    ],
                    "weatherIconUrl": [
                        {
                            "value": ""
                        }
                    ],
                    "winddir16Point": "NE",
                    "winddirDegree": "48",
                    "windspeedKmph": "4",
                    "windspeedMiles": "2"
                },
                {
                    "DewPointC": "2",
                    "DewPointF": "35",
                    "FeelsLikeC": "15",
                    "FeelsLikeF": "60",
                    "HeatIndexC": "15",
                    "HeatIndexF": "60",
                    "WindChillC": "15",
                    "WindChillF": "60",
                    "WindGustKmph": "5",
                    "WindGustMiles": "3",
                    "chanceoffog": "0",
                    "chanceoffrost": "0",
                    "chanceofhightemp": "0",
                    "chanceofovercast": "0",
                    "chanceofrain": "0",
                    "chanceofremdry": "88",
                    "chanceofsnow": "0",
                    "chanceofsunshine": "86",
                    "chanceofthunder": "0",
                    "chanceofwindy": "0",
                    "cloudcover": "12",
                    "humidity": "39",
                    "precipInches": "0.0",
                    "precipMM": "0.0",
                    "pressure": "1026",
                    "pressureInches": "30",
                    "tempC": "15",
                    "tempF": "60",
                    "time": "1500",
                    "uvIndex": "5",
                    "visibility": "10",
                    "visibilityMiles": "6",
                    "weatherCode": "113",
                    "weatherDesc": [
                        {
                            "value": "Sunny"
                        }
                    ],
                    "weatherIconUrl": [
                        {
                            "value": ""
                        }
                    ],
                    "winddir16Point": "WNW",
                    "winddirDegree": "296",
                    "windspeedKmph": "5",
                    "windspeedMiles": "3"
                },
                {
                    "DewPointC": "1",
                    "DewPointF": "33",
                    "FeelsLikeC": "13",
                    "FeelsLikeF": "55",
                    "HeatIndexC": "13",
                    "HeatIndexF": "56",
                    "WindChillC": "13",
                    "WindChillF": "55",
                    "WindGustKmph": "12",
                    "WindGustMiles": "8",
                    "chanceoffog": "0",
                    "chanceoffrost": "0",
                    "chanceofhightemp": "0",
                    "chanceofovercast": "39",
                    "chanceofrain": "0",
                    "chanceofremdry": "91",
                    "chanceofsnow": "0",
                    "chanceofsunshine": "80",
                    "chanceofthunder": "0",
                    "chanceofwindy": "0",
                    "cloudcover": "49",
                    "humidity": "42",
                    "precipInches": "0.0",
                    "precipMM": "0.0",
                    "pressure": "1027",
                    "pressureInches": "30",
                    "tempC": "13",
                    "tempF": "56",
                    "time": "1800",
                    "uvIndex": "1",
                    "visibility": "10",
                    "visibilityMiles": "6",
                    "weatherCode": "116",
                    "weatherDesc": [
                        {
                            "value": "Partly cloudy"
                        }
                    ],
                    "weatherIconUrl": [
                        {
                            "value": ""
                        }
                    ],
                    "winddir16Point": "W",
                    "winddirDegree": "278",
                    "windspeedKmph": "9",
                    "windspeedMiles": "5"
                },
                {
                    "DewPointC": "0",
                    "DewPointF": "32",
                    "FeelsLikeC": "11",
                    "FeelsLikeF": "51",
                    "HeatIndexC": "11",
                    "HeatIndexF": "52",
                    "WindChillC": "11",
                    "WindChillF": "51",
                    "WindGustKmph": "12",
                    "WindGustMiles": "8",
                    "chanceoffog": "0",
                    "chanceoffrost": "0",
                    "chanceofhightemp": "0",
                    "chanceofovercast": "90",
                    "chanceofrain": "0",
                    "chanceofremdry": "87",
                    "chanceofsnow": "0",
                    "chanceofsunshine": "16",
                    "chanceofthunder": "0",
                    "chanceofwindy": "0",
                    "cloudcover": "77",
                    "humidity": "46",
                    "precipInches": "0.0",
                    "precipMM": "0.0",
                    "pressure": "1027",
                    "pressureInches": "30",
                    "tempC": "11",
                    "tempF": "52",
                    "time": "2100",
                    "uvIndex": "1",
                    "visibility": "10",
                    "visibilityMiles": "6",
                    "weatherCode": "119",
                    "weatherDesc": [
                        {
                            "value": "Cloudy"
                        }
                    ],
                    "weatherIconUrl": [
                        {
                            "value": ""
                        }
                    ],
                    "winddir16Point": "E",
                    "winddirDegree": "90",
                    "windspeedKmph": "7",
                    "windspeedMiles": "4"
                }
            ],
            "maxtempC": "15",
            "maxtempF": "60",
            "mintempC": "6",
            "mintempF": "42",
            "sunHour": "11.6",
            "totalSnow_cm": "0.0",
            "uvIndex": "4"
        },
        {
            "astronomy": [
                {
                    "moon_illumination": "9",
                    "moon_phase": "Waning Crescent",
                    "moonrise": "05:05 AM",
                    "moonset": "02:39 PM",
                    "sunrise": "06:43 AM",
                    "sunset": "06:01 PM"
                }
            ],
            "avgtempC": "13",
            "avgtempF": "56",
            "date": "2022-02-27",
            "hourly": [
                {
                    "DewPointC": "0",
                    "DewPointF": "32",
                    "FeelsLikeC": "11",
                    "FeelsLikeF": "51",
                    "HeatIndexC": "11",
                    "HeatIndexF": "51",
                    "WindChillC": "11",
                    "WindChillF": "51",
                    "WindGustKmph": "1",
                    "WindGustMiles": "0",
                    "chanceoffog": "0",
                    "chanceoffrost": "0",
                    "chanceofhightemp": "0",
                    "chanceofovercast": "92",
                    "chanceofrain": "0",
                    "chanceofremdry": "86",
                    "chanceofsnow": "0",
                    "chanceofsunshine": "11",
                    "chanceofthunder": "0",
                    "chanceofwindy": "0",
                    "cloudcover": "74",
                    "humidity": "47",
                    "precipInches": "0.0",
                    "precipMM": "0.0",
                    "pressure": "1028",
                    "pressureInches": "30",
                    "tempC": "11",
                    "tempF": "51",
                    "time": "0",
                    "uvIndex": "1",
                    "visibility": "10",
                    "visibilityMiles": "6",
                    "weatherCode": "119",
                    "weatherDesc": [
                        {
                            "value": "Cloudy"
                        }
                    ],
                    "weatherIconUrl": [
                        {
                            "value": ""
                        }
                    ],
                    "winddir16Point": "WNW",
                    "winddirDegree": "297",
                    "windspeedKmph": "0",
                    "windspeedMiles": "0"
                },
                {
                    "DewPointC": "0",
                    "DewPointF": "32",
                    "FeelsLikeC": "10",
                    "FeelsLikeF": "50",
                    "HeatIndexC": "10",
                    "HeatIndexF": "50",
                    "WindChillC": "10",
                    "WindChillF": "50",
                    "WindGustKmph": "7",
                    "WindGustMiles": "4",
                    "chanceoffog": "0",
                    "chanceoffrost": "0",
                    "chanceofhightemp": "0",
                    "chanceofovercast": "38",
                    "chanceofrain": "0",
                    "chanceofremdry": "85",
                    "chanceofsnow": "0",
                    "chanceofsunshine": "86",
                    "chanceofthunder": "0",
                    "chanceofwindy": "0",
                    "cloudcover": "29",
                    "humidity": "51",
                    "precipInches": "0.0",
                    "precipMM": "0.0",
                    "pressure": "1028",
                    "pressureInches": "30",
                    "tempC": "10",
                    "tempF": "50",
                    "time": "300",
                    "uvIndex": "1",
                    "visibility": "10",
                    "visibilityMiles": "6",
                    "weatherCode": "116",
                    "weatherDesc": [
                        {
                            "value": "Partly cloudy"
                        }
                    ],
                    "weatherIconUrl": [
                        {
                            "value": ""
                        }
                    ],
                    "winddir16Point": "NW",
                    "winddirDegree": "326",
                    "windspeedKmph": "4",
                    "windspeedMiles": "2"
                },
                {
                    "DewPointC": "0",
                    "DewPointF": "32",
                    "FeelsLikeC": "9",
                    "FeelsLikeF": "48",
                    "HeatIndexC": "9",
                    "HeatIndexF": "48",
                    "WindChillC": "9",
                    "WindChillF": "48",
                    "WindGustKmph": "7",
                    "WindGustMiles": "4",
                    "chanceoffog": "0",
                    "chanceoffrost": "0",
                    "chanceofhightemp": "0",
                    "chanceofovercast": "0",
                    "chanceofrain": "0",
                    "chanceofremdry": "92",
                    "chanceofsnow": "0",
                    "chanceofsunshine": "91",
                    "chanceofthunder": "0",
                    "chanceofwindy": "0",
                    "cloudcover": "16",
                    "humidity": "54",
                    "precipInches": "0.0",
                    "precipMM": "0.0",
                    "pressure": "1029",
                    "pressureInches": "30",
                    "tempC": "9",
                    "tempF": "48",
                    "time": "600",
                    "uvIndex": "1",
                    "visibility": "10",
                    "visibilityMiles": "6",
                    "weatherCode": "113",
                    "weatherDesc": [
                        {
                            "value": "Clear"
                        }
                    ],
                    "weatherIconUrl": [
                        {
                            "value": ""
                        }
                    ],
                    "winddir16Point": "N",
                    "winddirDegree": "1",
                    "windspeedKmph": "4",
                    "windspeedMiles": "2"
                },
                {
                    "DewPointC": "0",
                    "DewPointF": "32",
                    "FeelsLikeC": "10",
                    "FeelsLikeF": "51",
                    "HeatIndexC": "10",
                    "HeatIndexF": "50",
                    "WindChillC": "10",
                    "WindChillF": "51",
                    "WindGustKmph": "6",
                    "WindGustMiles": "4",
                    "chanceoffog": "0",
                    "chanceoffrost": "0",
                    "chanceofhightemp": "0",
                    "chanceofovercast": "0",
                    "chanceofrain": "0",
                    "chanceofremdry": "86",
                    "chanceofsnow": "0",
                    "chanceofsunshine": "88",
                    "chanceofthunder": "0",
                    "chanceofwindy": "0",
                    "cloudcover": "10",
                    "humidity": "50",
                    "precipInches": "0.0",
                    "precipMM": "0.0",
                    "pressure": "1030",
                    "pressureInches": "30",
                    "tempC": "10",
                    "tempF": "50",
                    "time": "900",
                    "uvIndex": "4",
                    "visibility": "10",
                    "visibilityMiles": "6",
                    "weatherCode": "113",
                    "weatherDesc": [
                        {
                            "value": "Sunny"
                        }
                    ],
                    "weatherIconUrl": [
                        {
                            "value": ""
                        }
                    ],
                    "winddir16Point": "ENE",
                    "winddirDegree": "72",
                    "windspeedKmph": "4",
                    "windspeedMiles": "2"
                },
                {
                    "DewPointC": "2",
                    "DewPointF": "35",
                    "FeelsLikeC": "17",
                    "FeelsLikeF": "62",
                    "HeatIndexC": "17",
                    "HeatIndexF": "62",
                    "WindChillC": "17",
                    "WindChillF": "62",
                    "WindGustKmph": "5",
                    "WindGustMiles": "3",
                    "chanceoffog": "0",
                    "chanceoffrost": "0",
                    "chanceofhightemp": "0",
                    "chanceofovercast": "0",
                    "chanceofrain": "0",
                    "chanceofremdry": "94",
                    "chanceofsnow": "0",
                    "chanceofsunshine": "92",
                    "chanceofthunder": "0",
                    "chanceofwindy": "0",
                    "cloudcover": "7",
                    "humidity": "36",
                    "precipInches": "0.0",
                    "precipMM": "0.0",
                    "pressure": "1029",
                    "pressureInches": "30",
                    "tempC": "17",
                    "tempF": "62",
                    "time": "1200",
                    "uvIndex": "5",
                    "visibility": "10",
                    "visibilityMiles": "6",
                    "weatherCode": "113",
                    "weatherDesc": [
                        {
                            "value": "Sunny"
                        }
                    ],
                    "weatherIconUrl": [
                        {
                            "value": ""
                        }
                    ],
                    "winddir16Point": "NNE",
                    "winddirDegree": "30",
                    "windspeedKmph": "4",
                    "windspeedMiles": "2"
                },
                {
                    "DewPointC": "3",
                    "DewPointF": "37",
                    "FeelsLikeC": "19",
                    "FeelsLikeF": "66",
                    "HeatIndexC": "19",
                    "HeatIndexF": "66",
                    "WindChillC": "19",
                    "WindChillF": "66",
                    "WindGustKmph": "9",
                    "WindGustMiles": "6",
                    "chanceoffog": "0",
                    "chanceoffrost": "0",
                    "chanceofhightemp": "0",
                    "chanceofovercast": "0",
                    "chanceofrain": "0",
                    "chanceofremdry": "91",
                    "chanceofsnow": "0",
                    "chanceofsunshine": "91",
                    "chanceofthunder": "0",
                    "chanceofwindy": "0",
                    "cloudcover": "3",
                    "humidity": "34",
                    "precipInches": "0.0",
                    "precipMM": "0.0",
                    "pressure": "1026",
                    "pressureInches": "30",
                    "tempC": "19",
                    "tempF": "66",
                    "time": "1500",
                    "uvIndex": "5",
                    "visibility": "10",
                    "visibilityMiles": "6",
                    "weatherCode": "113",
                    "weatherDesc": [
                        {
                            "value": "Sunny"
                        }
                    ],
                    "weatherIconUrl": [
                        {
                            "value": ""
                        }
                    ],
                    "winddir16Point": "WNW",
                    "winddirDegree": "299",
                    "windspeedKmph": "8",
                    "windspeedMiles": "5"
                },
                {
                    "DewPointC": "5",
                    "DewPointF": "42",
                    "FeelsLikeC": "18",
                    "FeelsLikeF": "64",
                    "HeatIndexC": "18",
                    "HeatIndexF": "64",
                    "WindChillC": "18",
                    "WindChillF": "64",
                    "WindGustKmph": "12",
                    "WindGustMiles": "7",
                    "chanceoffog": "0",
                    "chanceoffrost": "0",
                    "chanceofhightemp": "0",
                    "chanceofovercast": "0",
                    "chanceofrain": "0",
                    "chanceofremdry": "83",
                    "chanceofsnow": "0",
                    "chanceofsunshine": "90",
                    "chanceofthunder": "0",
                    "chanceofwindy": "0",
                    "cloudcover": "0",
                    "humidity": "43",
                    "precipInches": "0.0",
                    "precipMM": "0.0",
                    "pressure": "1026",
                    "pressureInches": "30",
                    "tempC": "18",
                    "tempF": "64",
                    "time": "1800",
                    "uvIndex": "5",
                    "visibility": "10",
                    "visibilityMiles": "6",
                    "weatherCode": "113",
                    "weatherDesc": [
                        {
                            "value": "Sunny"
                        }
                    ],
                    "weatherIconUrl": [
                        {
                            "value": ""
                        }
                    ],
                    "winddir16Point": "W",
                    "winddirDegree": "271",
                    "windspeedKmph": "10",
                    "windspeedMiles": "6"
                },
                {
                    "DewPointC": "5",
                    "DewPointF": "42",
                    "FeelsLikeC": "12",
                    "FeelsLikeF": "53",
                    "HeatIndexC": "12",
                    "HeatIndexF": "53",
                    "WindChillC": "12",
                    "WindChillF": "53",
                    "WindGustKmph": "11",
                    "WindGustMiles": "7",
                    "chanceoffog": "0",
                    "chanceoffrost": "0",
                    "chanceofhightemp": "0",
                    "chanceofovercast": "0",
                    "chanceofrain": "0",
                    "chanceofremdry": "83",
                    "chanceofsnow": "0",
                    "chanceofsunshine": "87",
                    "chanceofthunder": "0",
                    "chanceofwindy": "0",
                    "cloudcover": "16",
                    "humidity": "64",
                    "precipInches": "0.0",
                    "precipMM": "0.0",
                    "pressure": "1027",
                    "pressureInches": "30",
                    "tempC": "12",
                    "tempF": "53",
                    "time": "2100",
                    "uvIndex": "1",
                    "visibility": "10",
                    "visibilityMiles": "6",
                    "weatherCode": "113",
                    "weatherDesc": [
                        {
                            "value": "Clear"
                        }
                    ],
                    "weatherIconUrl": [
                        {
                            "value": ""
                        }
                    ],
                    "winddir16Point": "WNW",
                    "winddirDegree": "292",
                    "windspeedKmph": "6",
                    "windspeedMiles": "4"
                }
            ],
            "maxtempC": "20",
            "maxtempF": "68",
            "mintempC": "9",
            "mintempF": "47",
            "sunHour": "11.6",
            "totalSnow_cm": "0.0",
            "uvIndex": "3"
        }
    ]
}

JavaScript Parser reliability

I ported some of esbuild's tests to bun's testing library and that led to uncovering & fixing some parser bugs

// what some of the tests look like
expectParseError("-x.y() ** 2", "Unexpected **");
expectParseError("+x.y() ** 2", "Unexpected **");
expectParseError("~x.y() ** 2", "Unexpected **");
expectParseError("!x.y() ** 2", "Unexpected **");
expectParseError("void x.y() ** 2", "Unexpected **");
expectParseError("delete x.y() ** 2", "Unexpected **");
expectParseError("typeof x.y() ** 2", "Unexpected **");

New features

type inside of import clauses is now supported. This is a TypeScript feature.

// previously, this would error
import {type FooType} from 'bar';

Import assertions are now parsed by bun. Currently, they're removed from the final output

import("./foo.json", { type: "json" });
// ⬇️
import("./foo.json");

import json from "./foo.json" assert { type: "json" };
// ⬇️
import json from "./foo.json";

Fixed a number of whitespace/formatting bugs with the printer

bun install reliability

This release brings bun install much closer to something you can use daily. It's not there yet, but it is close.

Somewhat controversially, bun install uses a binary lockfile format. One thing several people asked for: a hash. So I added a hash.

> bun pm hash
1A0FF3DFFE05333A-b20fd0e1259d2de5-9E3B657EA8BD4436-9f3132e0eb95a60e

This is a SHA512/256 hash of the following string. The string is created by looping through all the resolved packages in the lockfile, sorting alphabetically, then sorting any packages with multiple duplicate versions.

> bun pm hash-string
-- BEGIN SHA512/256(`${alphabetize(name)}@${order(version)}`) --
@types/node@16.11.26
@types/puppeteer@5.4.5
camel-case@4.1.2
capital-case@1.0.4
change-case@4.1.2
constant-case@3.0.4
dot-case@3.0.4
header-case@2.0.4
js-tokens@4.0.0
loose-envify@1.4.0
lower-case@2.0.2
no-case@3.0.4
object-assign@4.1.1
param-case@3.0.4
pascal-case@3.1.2
path-case@3.0.4
peechy@0.4.24
prettier@2.5.1
react@17.0.2
sentence-case@3.0.4
snake-case@3.0.4
tslib@2.3.1
upper-case@2.0.2
upper-case-first@2.0.2
-- END HASH--

bun pm is a new subcommand for "miscellaneous package manager things"

> bun pm
bun pm - package manager related commands

  bun pm bin          print the path to bin folder
  bun pm -g bin       print the global path to bin folder
  bun pm hash         generate & print the hash of the current lockfile
  bun pm hash-string  print the string used to hash the lockfile
  bun pm hash-print   print the hash stored in the current lockfile

When using bun install -y, the hash is inserted into the saved yarn.lock:

# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
# bun ./bun.lockb --hash: 3982DAEC20B10CF8-4da4f73e6f1d3ab1-77B62BB40B50C631-a7674fe7d3217550

You can now configure bun install with bunfig.toml. it will search for bunfig.toml in $XDG_CONFIG_HOME/bunfig.toml and $HOME/bunfig.toml, in addition to ./bunfig.toml

bun install bugfixes

bun run

bun bun

bun dev

Open-in-editor is now implemented

Screen Recording 2022-02-25 at 5 15 01 AM

Bun.js

Other

try running bun wiptest in a project that uses jest

it'll probably throw a not implemented error, but it might work

相关地址:原始地址 下载(tar) 下载(zip)

1、 bun-darwin-aarch64.dSYM.tar.gz 117.48MB

2、 bun-darwin-aarch64.zip 11.48MB

3、 bun-darwin-x64.dSYM.tar.gz 117.1MB

4、 bun-darwin-x64.zip 13.59MB

5、 bun-linux-x64.zip 24.07MB

查看:2022-02-25发行的版本