hn.today

Jev-Leftpad

github.com146 points51 comments
Screenshot of Jev-Leftpad

jev-leftpad is an npm package that left-pads a string by calling TypeSafe AI’s Jev model instead of using String.prototype.padStart. Installation and usage are straightforward: npm install jev-leftpad, import leftPad from 'jev-leftpad', set TYPESAFE_API_KEY, and call await leftPad(value, targetLength). The package uses jev-latest via @typesafe-ai/sdk and requires Node.js 20+. An example leftPad('jev', 8) should return five leading spaces plus "jev". The README acknowledges that padStart could do this in one line but intentionally routes the task through a model call.

The implementation and limits are explicit: the API function accepts a non-negative safe integer targetLength; Jev receives a set of prewritten choices named space_0 through space_10, so the package can add between 0 and 10 spaces only. Each call issues one TypeSafe API request with retries disabled, so requests can fail, return the wrong choice, and are more expensive than a local method; the README warns against production use. Tests mock Jev and do not require an API key or TypeSafe credits. The project includes npm test/dev instructions and is published under the MIT license.

Read on github.com51 comments on Hacker News

Summary generated by AI from the linked article. hn.today is not affiliated with Hacker News or Y Combinator.

More in Other

Effective Altruism Is Evil

Effective Altruism Is Evil

Trey Goff argues that effective altruism is an evil ideology that promotes a utilitarian and consequentialist approach to maximizing the reduction of suffering, often through mathematical calculations. He claims it leads to systemic problems by prioritizing the greatest good for the greatest number, including non-human beings, over individual moral considerations. (twitter.com)

The daily digest

Today's best Hacker News stories, summarized and screenshotted, one email a day.