{"action":"created","issue":{"url":"https://api.github.com/repos/wearefractal/glob-stream/issues/33","labels_url":"https://api.github.com/repos/wearefractal/glob-stream/issues/33/labels{/name}","comments_url":"https://api.github.com/repos/wearefractal/glob-stream/issues/33/comments","events_url":"https://api.github.com/repos/wearefractal/glob-stream/issues/33/events","html_url":"https://github.com/wearefractal/glob-stream/pull/33","id":53211732,"number":33,"title":"Avoid creating multiple Minimatch instances for the same negative glob","user":{"login":"UltCombo","id":2090712,"avatar_url":"https://avatars.githubusercontent.com/u/2090712?v=3","gravatar_id":"","url":"https://api.github.com/users/UltCombo","html_url":"https://github.com/UltCombo","followers_url":"https://api.github.com/users/UltCombo/followers","following_url":"https://api.github.com/users/UltCombo/following{/other_user}","gists_url":"https://api.github.com/users/UltCombo/gists{/gist_id}","starred_url":"https://api.github.com/users/UltCombo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/UltCombo/subscriptions","organizations_url":"https://api.github.com/users/UltCombo/orgs","repos_url":"https://api.github.com/users/UltCombo/repos","events_url":"https://api.github.com/users/UltCombo/events{/privacy}","received_events_url":"https://api.github.com/users/UltCombo/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2015-01-01T02:49:53Z","updated_at":"2015-01-02T08:47:48Z","closed_at":"2015-01-02T08:30:22Z","pull_request":{"url":"https://api.github.com/repos/wearefractal/glob-stream/pulls/33","html_url":"https://github.com/wearefractal/glob-stream/pull/33","diff_url":"https://github.com/wearefractal/glob-stream/pull/33.diff","patch_url":"https://github.com/wearefractal/glob-stream/pull/33.patch"},"body":"This optimizes use cases such as `['a', 'b', '!b']`, where a new Minimatch instance for `'!b'` would be created for each previous positive glob.\r\n\r\nNow the Minimatch instances for negative globs are created beforehand, thus positive globs can use the same negative matcher instances. That is, for `['a', 'b', '!b']` both `'a'` and `'b'` globs will use the same Minimatch instance for `'!b'` instead of instantiating their own.\r\n\r\nAlso, as far as I can see, `gs.createStream` is internal (no docs or tests), so I took the liberty of adapting it a bit as I needed the complete `opt` object to pass to the Minimatch constructor in `gs.create`.\r\n\r\nShould also note that this change, technically, would instantiate Minimatch instances that would never be used when considering leading negative globs (e.g. `['!b', 'b']`), but that is a complete misuse and IIRC Minimatch produces their underlying regex lazily, so this shouldn't be a problem."},"comment":{"url":"https://api.github.com/repos/wearefractal/glob-stream/issues/comments/68514070","html_url":"https://github.com/wearefractal/glob-stream/pull/33#issuecomment-68514070","issue_url":"https://api.github.com/repos/wearefractal/glob-stream/issues/33","id":68514070,"user":{"login":"UltCombo","id":2090712,"avatar_url":"https://avatars.githubusercontent.com/u/2090712?v=3","gravatar_id":"","url":"https://api.github.com/users/UltCombo","html_url":"https://github.com/UltCombo","followers_url":"https://api.github.com/users/UltCombo/followers","following_url":"https://api.github.com/users/UltCombo/following{/other_user}","gists_url":"https://api.github.com/users/UltCombo/gists{/gist_id}","starred_url":"https://api.github.com/users/UltCombo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/UltCombo/subscriptions","organizations_url":"https://api.github.com/users/UltCombo/orgs","repos_url":"https://api.github.com/users/UltCombo/repos","events_url":"https://api.github.com/users/UltCombo/events{/privacy}","received_events_url":"https://api.github.com/users/UltCombo/received_events","type":"User","site_admin":false},"created_at":"2015-01-02T08:47:48Z","updated_at":"2015-01-02T08:47:48Z","body":"No problem, though, I believe lost a bit of readability, seeing as negatives' `glob` property now holds either a RegExp or Minimatch instance, which is a little counterproductive. Perhaps it would be cleaner if this patch was similar to the one I submitted to globby (https://github.com/sindresorhus/globby/commit/e402d9fbb6d16f2c4f1464d8323fefd16116af04), that is, iterating over the negatives and creating a `matcher` property."}}