Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import arrayUniq from 'array-uniq';
const a: Array = arrayUniq([1, 1, 2, 3, 3]);
//=> [1, 2, 3]
const b: Array = arrayUniq(['foo', 'foo', 'bar', 'foo']);
//=> ['foo', 'bar']
// $ExpectError
const c: Array = arrayUniq([1, 2, 3]);
import arrayUniq from 'array-uniq';
const a: Array = arrayUniq([1, 1, 2, 3, 3]);
//=> [1, 2, 3]
const b: Array = arrayUniq(['foo', 'foo', 'bar', 'foo']);
//=> ['foo', 'bar']
// $ExpectError
const c: Array = arrayUniq([1, 2, 3]);
await Promise.all(this.src().map(src => { // eslint-disable-line array-callback-return
const options = {...this.options, ...src.options};
const sizes = arrayUniq(src.sizes.filter(/./.test, /^\d{2,4}x\d{2,4}$/i));
const keywords = arrayDiffer(src.sizes, sizes);
if (!src.url) {
throw new Error('URL required');
}
this.urls.push(src.url);
if (sizes.length === 0 && keywords.indexOf('w3counter') !== -1) {
return this.resolution(src.url, options);
}
if (keywords.length > 0) {
return this.viewport({url: src.url, sizes, keywords}, options);
}
remove(collection) {
collection = arrayUnique(collection);
let items = collection
.map(element => this.getItemByElement(element))
.filter(item => !!item);
if (!collection.length) {
return;
}
let handleLayout = () => {
this.element.removeEventListener(Shuffle.EventType.LAYOUT, handleLayout);
this._disposeItems(items);
// Remove the collection in the callback
collection.forEach((element) => {
element.parentNode.removeChild(element);
if (sizes.length === 0 && keywords.indexOf('w3counter') !== -1) {
return this.resolution(src.url, options);
}
if (keywords.length > 0) {
return this.viewport({url: src.url, sizes, keywords}, options);
}
for (const size of sizes) {
this.sizes.push(size);
this.items.push(this.create(src.url, size, options));
}
}));
this.stats.urls = arrayUniq(this.urls).length;
this.stats.sizes = arrayUniq(this.sizes).length;
this.stats.screenshots = this.items.length;
if (!this.dest()) {
return this.items;
}
await this.save(this.items);
return this.items;
}
if (sizes.length === 0 && keywords.indexOf('w3counter') !== -1) {
return this.resolution(src.url, options);
}
if (keywords.length > 0) {
return this.viewport({url: src.url, sizes, keywords}, options);
}
for (const size of sizes) {
this.sizes.push(size);
this.items.push(this.create(src.url, size, options));
}
}));
this.stats.urls = arrayUniq(this.urls).length;
this.stats.sizes = arrayUniq(this.sizes).length;
this.stats.screenshots = this.items.length;
if (!this.dest()) {
return this.items;
}
await this.save(this.items);
return this.items;
}
let getUniqueNames = node => {
let names = [
...new Set(getAllAnimatedProps(node, false).map(prop => prop.name)),
]
return uniq(names.map(name => ensurePropName(name))).join(', ')
}
async viewport(obj: Viewport, options: Options) {
for (const item of await viewportListMem(obj.keywords)) {
this.sizes.push(item.size);
obj.sizes.push(item.size);
}
for (const size of arrayUniq(obj.sizes)) {
this.items.push(this.create(obj.url, size, options));
}
}
constructor(props) {
super(props);
this.displayName = 'AnimatedElement';
this.attrNames = this.getAttrNames();
this.derivedAttrNames = this.getDerivedAttrNames();
this.derivedAttrDefaults = this.getDerivedAttrDefaults();
this.derivedAttrInputNames = this.getDerivedAttrInputNames();
this.privatePropNames = this.getPrivatePropNames().concat(PRIVATE_PROP_NAMES);
this.allAttrInputNames = this.attrNames.concat(
Object.keys(this.derivedAttrInputNames).reduce((acc, key) =>
acc.concat(this.derivedAttrInputNames[key])
, [])
);
this.allDerivedAttrInputNames = uniq(
Object.keys(this.derivedAttrInputNames)
.reduce((acc, key) =>
acc.concat(this.derivedAttrInputNames[key])
, [])
);
this.propsToCheckForChanges = ['datum'].concat(this.props.propsToCheckForChanges);
this.attrs = this.getAttrs(this.props);
this.state = this.getState();
}