Idx.macro
a 'babel-macros' version of 'babel-plugin-idx'
Install / Use
/learn @dralletje/Idx.macroREADME
idx.macro
No longer necessary 🍾 🎉
The day has arrived! A lot of environments now support Optional Chaining, which does exactly what this macro does but better looking (and native and blablabla but I care about the looksss 😎 😏 ).
Not sure if there is any use for this, as most people that have babel-macros support most likely also have babel doing optional chaining now.. Idk I'll leave this up for now and maybe archive when I look back in a year or so 🤷♀️
idx.macro
This is a babel-macros version of the babel plugin idx.
idx is a utility function for traversing properties on objects and arrays.
If an intermediate property is either null or undefined, it is instead returned. The purpose of this function is to simplify extracting properties from a chain of maybe-typed properties.
Usage
With babel-macros and this package installed, you can use it to like idx.
import idx from 'idx.macro';
const fiends_of_friends = idx(props, _ => _.user.friends[0].friends);
The above snippet will be compiled to:
const fiends_of_friends =
props.user == null ? props.user :
props.user.friends == null ? props.user.friends :
props.user.friends[0] == null ? props.user.friends[0] :
props.user.friends[0].friends
License
idx is MIT licensed. I copied it from the facebook idx license.
I have no idea if I am doing this right (what is the PATENTS file?!), so please
let me know if you know anything about this.
If the facebook people want to have idx.macro on their idx repo, or want the idx.macro name, just sent me a message :)
Related Skills
node-connect
350.8kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
110.4kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
350.8kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
350.8kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
