es6-shorthands
raw JSON → 0.0.2 verified Fri May 01 auth: no javascript maintenance
A tiny transpiler (v0.0.2) that converts ES6 shorthand method syntax in object literals (e.g., `{a, b() {}}`) to ES5 equivalents (`{a: a, b: function b() {}}`). It is a simple, single-purpose tool that performs a string-based transformation, not a full-featured compiler like Babel. Published as a proof-of-concept, it has not seen updates since initial release and is in maintenance mode. Useful only for legacy build pipelines that need a minimal ES6 shorthand transformation without a larger toolchain. Not suitable for production use.
Common errors
error shorthand is not a function ↓
cause Importing as `{ shorthand }` instead of default import.
fix
Use
import shorthand from 'es6-shorthands' or const shorthand = require('es6-shorthands').default. error Cannot find module 'es6-shorthands' ↓
cause Package not installed or not resolved correctly.
fix
Run
npm install es6-shorthands --save-dev and ensure it's in node_modules. Warnings
gotcha String replacement may incorrectly transform strings containing shorthand-like patterns (e.g., JSON or template literals). ↓
fix Use a proper parser-based tool like Babel for production code.
deprecated Package is effectively unmaintained; last version 0.0.2 from 2015-08-20. ↓
fix Migrate to Babel or TypeScript for ES6+ transpilation.
breaking No breaking changes documented due to minimal scope and single version. ↓
fix N/A
Install
npm install es6-shorthands yarn add es6-shorthands pnpm add es6-shorthands Imports
- default export (function) wrong
const { shorthand } = require('es6-shorthands')correctimport shorthand from 'es6-shorthands' - TypeScript type import wrong
import { type ShorthandOptions } from 'es6-shorthands'correctimport type { ShorthandOptions } from 'es6-shorthands' - require in ESM context wrong
const shorthand = require('es6-shorthands')correctimport shorthand from 'es6-shorthands'
Quickstart
import shorthand from 'es6-shorthands';
const source = `const obj = { a, b() { return 5; } };`;
const result = shorthand(source);
console.log(result);
// Output: const obj = { a: a, b: function b() { return 5; } };