Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@dojo/shim

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dojo/shim - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1

24

iterator.d.ts

@@ -43,1 +43,25 @@ import './Symbol';

export declare function isArrayLike(value: any): value is ArrayLike<any>;
/**
* Returns the iterator for an object
*
* @param iterable The iterable object to return the iterator for
*/
export declare function get<T>(iterable: Iterable<T> | ArrayLike<T>): Iterator<T> | undefined;
export interface ForOfCallback<T> {
/**
* A callback function for a forOf() iteration
*
* @param value The current value
* @param object The object being iterated over
* @param doBreak A function, if called, will stop the iteration
*/
(value: T, object: Iterable<T> | ArrayLike<T> | string, doBreak: () => void): void;
}
/**
* Shims the functionality of `for ... of` blocks
*
* @param iterable The object the provides an interator interface
* @param callback The callback which will be called for each item of the iterable
* @param thisArg Optional scope to pass the callback
*/
export declare function forOf<T>(iterable: Iterable<T> | ArrayLike<T> | string, callback: ForOfCallback<T>, thisArg?: any): void;

62

iterator.js

@@ -7,3 +7,3 @@ (function (factory) {

else if (typeof define === "function" && define.amd) {
define(["require", "exports", "./Symbol"], factory);
define(["require", "exports", "./Symbol", "./string"], factory);
}

@@ -14,2 +14,3 @@ })(function (require, exports) {

require("./Symbol");
var string_1 = require("./string");
var staticDone = { done: true, value: undefined };

@@ -73,3 +74,62 @@ /**

exports.isArrayLike = isArrayLike;
/**
* Returns the iterator for an object
*
* @param iterable The iterable object to return the iterator for
*/
function get(iterable) {
if (isIterable(iterable)) {
return iterable[Symbol.iterator]();
}
else if (isArrayLike(iterable)) {
return new ShimIterator(iterable);
}
}
exports.get = get;
;
/**
* Shims the functionality of `for ... of` blocks
*
* @param iterable The object the provides an interator interface
* @param callback The callback which will be called for each item of the iterable
* @param thisArg Optional scope to pass the callback
*/
function forOf(iterable, callback, thisArg) {
var broken = false;
function doBreak() {
broken = true;
}
/* We need to handle iteration of double byte strings properly */
if (isArrayLike(iterable) && typeof iterable === 'string') {
var l = iterable.length;
for (var i = 0; i < l; ++i) {
var char = iterable[i];
if ((i + 1) < l) {
var code = char.charCodeAt(0);
if ((code >= string_1.HIGH_SURROGATE_MIN) && (code <= string_1.HIGH_SURROGATE_MAX)) {
char += iterable[++i];
}
}
callback.call(thisArg, char, iterable, doBreak);
if (broken) {
return;
}
}
}
else {
var iterator = get(iterable);
if (iterator) {
var result = iterator.next();
while (!result.done) {
callback.call(thisArg, result.value, iterable, doBreak);
if (broken) {
return;
}
result = iterator.next();
}
}
}
}
exports.forOf = forOf;
});
//# sourceMappingURL=iterator.js.map

2

package.json
{
"name": "@dojo/shim",
"version": "0.2.0",
"version": "0.2.1",
"description": "Modules that provide modular fills of ES6+ functionality",

@@ -5,0 +5,0 @@ "homepage": "https://dojo.io",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc