1.0.2 • Published 3 years ago

@kznjunk/pre-load v1.0.2

Weekly downloads
89
License
ISC
Repository
-
Last release
3 years ago

Pre-load

Quick Mode

const { preload } = require('@kznjunk/pre-load')

const itemsToPreload = [
  'img/hello.png',
  'snd/there.mp3',
  'snd/i-dont-exist.mp3'
]

const preloadedItems = await preload(itemsToPreload) // result: [ 'img/hello.png', 'snd/there.mp3', false ]

No extension case

const { preload } = require('@kznjunk/pre-load')

const itemsToPreload = [
  'img/hello?size=42x42',
  'img/there?size=108x108'
]

const options = {
  type: 'img'
}

const preloadedItems = await preload(itemsToPreload, options) // result: [ 'img/hello?size=42x42', 'img/there?size=108x108' ]

Callbacks & progress bar

const { preload } = require('@kznjunk/pre-load')

const itemsToPreload = [
  'img/hello.png',
  'snd/there.mp3'
]

const options = {
  cb_foreach: () => { console.log('Another one') },
  cb_then: () => { console.log('Annnnd it\'s done.') },
}

const preloadedItems = await preload(itemsToPreload, options) // result: [ 'img/hello.png', 'snd/there.mp3' ]

Real use case (todo..)

console.log('nothing to see here')
1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago