davidmarkclements / rfdc

Really Fast Deep Clone
MIT License
643 stars 25 forks source link

Allow importing a subpath with the default options being set #14

Open BridgeAR opened 4 years ago

BridgeAR commented 4 years ago

It would be a great addition to add a subpath such as rfdc/default that exports a cloning function with the default options being set. That way there's no need to do e.g.:

// Instead of:
import rfdc from 'rfdc'
const clone = rfdc()

// Then possible:
import clone from 'rfdc/default'
vieirai commented 4 years ago

@BridgeAR , @davidmarkclements is this being pushed to npm soon? I see that the fix was merged 4 days ago, but the npm package hasn't been updated yet :)

nicholaschiang commented 4 years ago

Any updates on this? Also, @BridgeAR, you haven't updated the Typescript definition file in #15. You'll want to do something like:

// index.d.ts
declare module 'rfdc/default' {
  export default function rfdc<T>(obj: T) => T;
}

And then make sure that those changes are either:

  1. Reflected in the DefinitelyTyped package, OR;
  2. Included in the package itself (i.e. add a types field in your package.json and then include index.d.ts in your NPM package).