This repository has been archived by the owner. It is now read-only.

Shim module for Set #115

Closed
wants to merge 22 commits into
base: master
from

Conversation

Projects
None yet
4 participants
@kitsonk
Member

kitsonk commented Feb 29, 2016

This module requires #74 and shims the functionality of Set, which offloads to native (when there is a compliant es6 Set implementation, IE 11 and older versions of Safari do not provide sufficient functionality, and so the shim is used in those situations).

@kitsonk kitsonk added this to the beta.1 milestone Feb 29, 2016

@kitsonk

This comment has been minimized.

Show comment
Hide comment
@kitsonk

kitsonk Feb 29, 2016

Member

I should also mention that it includes a module named iterator which provides a shim for common iterator type functionality, including the ability to replicate the for ... of type of iteration via a forOf() function. Where you can take something that defines a [Symbol.iterator] or iterators over anything that is ArrayLike, for example:

import { forOf } from 'dojo-core/iterator`;

const arr: number[] = [ 1, 2, 3 ];
forOf(arr, function (value, source, doBreak) {
  console.log(value);
  /* source is the original iterator object */
  /* doBreak() is a function which allows you to break the forOf loop */
});

Since it isn't possible to "shim" syntax, it isn't possible to offload to native fully, but it does grab whatever iterator might be available and iterates over that until done.

Member

kitsonk commented Feb 29, 2016

I should also mention that it includes a module named iterator which provides a shim for common iterator type functionality, including the ability to replicate the for ... of type of iteration via a forOf() function. Where you can take something that defines a [Symbol.iterator] or iterators over anything that is ArrayLike, for example:

import { forOf } from 'dojo-core/iterator`;

const arr: number[] = [ 1, 2, 3 ];
forOf(arr, function (value, source, doBreak) {
  console.log(value);
  /* source is the original iterator object */
  /* doBreak() is a function which allows you to break the forOf loop */
});

Since it isn't possible to "shim" syntax, it isn't possible to offload to native fully, but it does grab whatever iterator might be available and iterates over that until done.

@kitsonk

This comment has been minimized.

Show comment
Hide comment
@kitsonk

kitsonk Mar 1, 2016

Member

So, it appears that TypeScript treats Symbol as a special object and elides it from typing information in a declaration. So even with an explicit import it still got elided. It would then cause issues in that the resulting .d.ts in the distribution would have issues with Symbol not being found. The only work around I was able to get to work was to provide a global Symbol .d.ts file which consumers will need to include in the scope of the project (or include lib.es6.d.ts or any other polyfil that declares Symbol in the global scope). At that point, the typings will be correct and the run-time behaviour will be preserved.

Member

kitsonk commented Mar 1, 2016

So, it appears that TypeScript treats Symbol as a special object and elides it from typing information in a declaration. So even with an explicit import it still got elided. It would then cause issues in that the resulting .d.ts in the distribution would have issues with Symbol not being found. The only work around I was able to get to work was to provide a global Symbol .d.ts file which consumers will need to include in the scope of the project (or include lib.es6.d.ts or any other polyfil that declares Symbol in the global scope). At that point, the typings will be correct and the run-time behaviour will be preserved.

@jquerybot jquerybot added CLA: Error and removed CLA: Error labels Mar 16, 2016

@codecov-io

This comment has been minimized.

Show comment
Hide comment
@codecov-io

codecov-io Mar 17, 2016

Current coverage is 97.96%

Merging #115 into master will not affect coverage as of 37fead9

@@            master    #115   diff @@
======================================
  Files           50      50       
  Stmts         2700    2700       
  Branches       518     518       
  Methods        609     609       
======================================
  Hit           2645    2645       
  Partial          2       2       
  Missed          53      53       

Review entire Coverage Diff as of 37fead9

Powered by Codecov. Updated on successful CI builds.

codecov-io commented Mar 17, 2016

Current coverage is 97.96%

Merging #115 into master will not affect coverage as of 37fead9

@@            master    #115   diff @@
======================================
  Files           50      50       
  Stmts         2700    2700       
  Branches       518     518       
  Methods        609     609       
======================================
  Hit           2645    2645       
  Partial          2       2       
  Missed          53      53       

Review entire Coverage Diff as of 37fead9

Powered by Codecov. Updated on successful CI builds.

@kitsonk kitsonk referenced this pull request Mar 18, 2016

Closed

Distribution Formats #18

Show outdated Hide outdated src/Set.ts
Show outdated Hide outdated src/Set.ts
Show outdated Hide outdated src/Set.ts
Show outdated Hide outdated src/iterator.ts

@kitsonk kitsonk modified the milestones: 2016.04, beta.1 Apr 8, 2016

@kitsonk kitsonk referenced this pull request Apr 11, 2016

Closed

Symbol Shim #74

@kitsonk

This comment has been minimized.

Show comment
Hide comment
@kitsonk

kitsonk Apr 11, 2016

Member

@mwistrand if you could take one more look, specifically at the changes I made (and any outstanding feedback you don't think I addressed) and then I think I can land this. I didn't directly update the Symbol branch (#74) as I just figured I would do it all in this PR.

Member

kitsonk commented Apr 11, 2016

@mwistrand if you could take one more look, specifically at the changes I made (and any outstanding feedback you don't think I addressed) and then I think I can land this. I didn't directly update the Symbol branch (#74) as I just figured I would do it all in this PR.

@mwistrand

This comment has been minimized.

Show comment
Hide comment
@mwistrand

mwistrand Apr 11, 2016

Thanks, @kitsonk, for your responses and changes. Any concern/suggestion I had has been addressed, for both this and #74.

mwistrand commented Apr 11, 2016

Thanks, @kitsonk, for your responses and changes. Any concern/suggestion I had has been addressed, for both this and #74.

@kitsonk

This comment has been minimized.

Show comment
Hide comment
@kitsonk

kitsonk Apr 11, 2016

Member

Closed via a202350

Member

kitsonk commented Apr 11, 2016

Closed via a202350

@kitsonk kitsonk closed this Apr 11, 2016

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.