btoews / security-key

iOS SEP U2F
MIT License
78 stars 14 forks source link

Cleanup `Promise.resolve`s #1

Closed josh closed 8 years ago

josh commented 8 years ago

Silly nitpick I caught while reviewing the extension JS.

You can kinda pretend all return values within a then are automatically wrapped in Promise.resolve.

These two statements return the same promised wrapped 42:

You can also return Promise's at the end of then(), and it will be "flattened". So returning a type Promise has a different effect than any other value.

Second, instead of reject, you can simply throw inside a then().

To sum up, inside a then() block, you shouldn't need to use any Promise.*** helper.

To: @mastahyeti CC: @dgraham

btoews commented 8 years ago

Thanks @josh! Action.js is the result of "compiling" all the stuff from /JavaScript/common/, /JavaScript/extension/ and /JavaScript/extension.js using a custom XCode "build phase" (script). I'll copy these changes over to the source files and recompile things.

josh commented 8 years ago

Action.js is the result of "compiling" all the stuff from /JavaScript/common/, /JavaScript/extension/ and /JavaScript/extension.js using a custom XCode "build phase" (script). I'll copy these changes over to the source files and recompile things.

D'oh! my bad. Hopefully this at least makes sense.

btoews commented 8 years ago

Hopefully this at least makes sense.

Definitely. Much appreciated :bow: