Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[QUESTION] through.obj remove duplicate files using path #108

Closed
danny007in opened this issue May 26, 2021 · 3 comments
Closed

[QUESTION] through.obj remove duplicate files using path #108

danny007in opened this issue May 26, 2021 · 3 comments

Comments

@danny007in
Copy link

Because for thomas-darling/gulp-dependents#12

@rvagg
Copy link
Owner

rvagg commented May 26, 2021

Sorry, this is entirely a gulp question not a through2 one so you'll have to continue the conversation there. My guess would be that you should keep a list of files outside of the stream chain and within one of the streams in the chain be filtering out duplicates which you keep a record of in the list of files.

const files = {}

thing.pipe(through2.obj((f, _, cb) => {
  if (!files[f]) {
    files[f] = true
    this.write(f)
  }
  cb()
}).pipe(...)
...

or something like that (this is off the top of my head and likely the specific semantics are a little wrong cause I haven't had to author one for a few months! but hopefully you get the idea).

@rvagg rvagg closed this as completed May 26, 2021
@danny007in
Copy link
Author

How to get path, just tell me
let fileThing = through.obj(function (file: File, encoding: string, callback: (err?: any, data?: any) => void) {

console.log("🚀 ~ file: plugin.ts ~ line 69 ~ fileThing", fileThing)

it showing lots of things

@danny007in
Copy link
Author

How to get path, just tell me
let fileThing = through.obj(function (file: File, encoding: string, callback: (err?: any, data?: any) => void) {

console.log("🚀 ~ file: plugin.ts ~ line 69 ~ fileThing", fileThing)

it showing lots of things

Getting

🚀 ~ file: plugin.ts ~ line 69 ~ fileThing DestroyableTransform {
  _readableState: ReadableState {
    objectMode: true,
    highWaterMark: 16,
    buffer: BufferList { length: 0 },
    length: 0,
    pipes: null,
    pipesCount: 0,
    flowing: null,
    ended: false,
    endEmitted: false,
    reading: false,
    sync: false,
    needReadable: true,
    emittedReadable: false,
    readableListening: false,
    resumeScheduled: false,
    destroyed: false,
    defaultEncoding: 'utf8',
    awaitDrain: 0,
    readingMore: false,
    decoder: null,
    encoding: null
  },
  readable: true,
  _events: [Object: null prototype] {
    end: [Function: bound onceWrapper] { listener: [Function: onend] },
    prefinish: [Function: prefinish]
  },
  _eventsCount: 2,
  _maxListeners: undefined,
  _writableState: WritableState {
    objectMode: true,
    highWaterMark: 16,
    finalCalled: false,
    needDrain: false,
    ending: false,
    ended: false,
    finished: false,
    destroyed: false,
    decodeStrings: true,
    defaultEncoding: 'utf8',
    length: 0,
    writing: false,
    corked: 0,
    sync: true,
    bufferProcessing: false,
    onwrite: [Function (anonymous)],
    writecb: null,
    writelen: 0,
    bufferedRequest: null,
    lastBufferedRequest: null,
    pendingcb: 0,
    prefinished: false,
    errorEmitted: false,
    bufferedRequestCount: 0,
    corkedRequestsFree: CorkedRequest {
      next: null,
      entry: null,
      finish: [Function (anonymous)]
    }
  },
  writable: true,
  allowHalfOpen: true,
  _transformState: {
    afterTransform: [Function: bound afterTransform],
    needTransform: false,
    transforming: false,
    writecb: null,
    writechunk: null,
    writeencoding: null
  },
  _destroyed: false,
  _transform: [Function (anonymous)],
  _flush: [Function (anonymous)],
  [Symbol(kCapture)]: false
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants