Proposal: Discarding specific element when importing/re-exporting module
# Cyril Auburtin (5 years ago)
It's also possible to split that large 'A' file in 2, and have a possible third file merging them
export * from './numbers.js'
export * from './A-without-numbers.js'
It's also possible to split that large 'A' file in 2, and have a possible third file merging them ```js export * from './numbers.js' export * from './A-without-numbers.js' ``` On Sun, Oct 27, 2019 at 6:39 AM Sm In <sbshw1 at gmail.com> wrote: > # Proposal: `except` clause in ModuleItem > > Inspired by [Haskell’s import statement](https://wiki.haskell.org/Import) > > ## Concept Introduction > > Let’s say we have module A: > > ```js > // A.js > export const zero = 0; > export const one = 1; > export const two = 2; > export const three = 3; > export const four = 4; > // … > export const ten = 10; > ``` > > A has so many exported values. > Now Let’s say we want to re-export numbers between 0 to 9 in module B. > > ```js > // B.js > export { zero, one, two, three, four, five, six, seven, eight, nine } from > ‘./A.js’; > ``` > > Hmmm, This is too long to see, isn’t it? > How can we reduce this long, long export declaration? > “Exporting numbers between 0 to 9 in module B” is same statement as > “Exporting everything except ten from module B”. > So, what if we can rewrite export declaration above like this?: > > ```js > //B.js > export * except { ten } from ‘./A.js’; > ``` > > This would be not only simpler way but also shorter way. > > ## Uses cases > > When dealing with module that has too many exports to explicitly specify. > I.e when using Util libraries or functional programming libraries like > ramda, lodash, fp-ts and etc. > > ## Non-Formal shapes > > ``` > Import * except { elements… } from ‘module’; > > Export * except { elements… } from ‘module’; > ``` > > _______________________________________________ > es-discuss mailing list > es-discuss at mozilla.org > https://mail.mozilla.org/listinfo/es-discuss > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20191101/f3592dc9/attachment.html>
Proposal:
except
clause in ModuleItemInspired by [Haskell’s import statement](wiki.haskell.org/Import, wiki.haskell.org/Import)
Concept Introduction
Let’s say we have module A:
// A.js export const zero = 0; export const one = 1; export const two = 2; export const three = 3; export const four = 4; // … export const ten = 10;
A has so many exported values. Now Let’s say we want to re-export numbers between 0 to 9 in module B.
// B.js export { zero, one, two, three, four, five, six, seven, eight, nine } from ‘./A.js’;
Hmmm, This is too long to see, isn’t it? How can we reduce this long, long export declaration? “Exporting numbers between 0 to 9 in module B” is same statement as “Exporting everything except ten from module B”. So, what if we can rewrite export declaration above like this?:
//B.js export * except { ten } from ‘./A.js’;
This would be not only simpler way but also shorter way.
Uses cases
When dealing with module that has too many exports to explicitly specify. I.e when using Util libraries or functional programming libraries like ramda, lodash, fp-ts and etc.
Non-Formal shapes