Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

arrow-magic

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

arrow-magic

A great way to write simple arrow functions faster.

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
7
increased by16.67%
Maintainers
1
Weekly downloads
 
Created
Source

arrow-magic

A great way to write simple arrow functions faster.

npm version

Why arrow-magic?

Have you ever written code similar to the one below?

const aThing = anotherThing.map(thing => thing.name)

I'm sure you have.

How about something like this?

const aThing = anotherThing.map(x => x.name)

Probably also yes, because we are programmers, and we want to be efficient, so we name thing to just x because it's just used in that one place and it's pretty obvious what we want to do with it.

Let me show you an even more efficient way to do it, that gets rid of the x too!

const aThing = anotherThing.map($("name"))

Or maybe even like this.

const aThing = anotherThing.map($`name`)

Ain't that cool? I love it.

Installation

npm install arrow-magic
yarn add arrow-magic

Usage

Pretty simple.

import { $ } from "arrow-magic"

const aThing = anotherThing.map($("name"))

Why is it named $?

Well, why not?

Ruby uses &, and that seems fine. I like $, and I also export it as magic and as prop in case you want something more.. english than $.

If you like some other symbol/name, feel free to make a PR!

Is it any good?

Yes.

Do I lose anything by using this?

Not if you use the $("name") syntax. It even works with typescript and typechecking!

The $`name` syntax unfortunately loses typechecking. Maybe there is a way to keep it, but I couldn't find it. Please make a PR if you can make this happen!

Keywords

FAQs

Package last updated on 14 Dec 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc