mqfunctions
Advanced tools
Comparing version 0.1.0-alpha.1 to 0.1.0-alpha.2
@@ -1,2 +0,6 @@ | ||
import type { MqFunctions, HandlerFunction } from './index.d'; | ||
export declare const addMqFunction: (mqf: MqFunctions, id: string, fn: HandlerFunction) => void; | ||
import type { MqFunctions, HandlerFunction } from './MqFunctions' | ||
export declare const addMqFunction: ( | ||
mqf: MqFunctions, | ||
id: string, | ||
fn: HandlerFunction, | ||
) => void |
@@ -1,2 +0,2 @@ | ||
import type { MqFunctions } from './index.d'; | ||
export declare const createMqFunctions: (query: string) => MqFunctions; | ||
import type { MqFunctions } from './MqFunctions' | ||
export declare const createMqFunctions: (query: string) => MqFunctions |
@@ -0,7 +1,15 @@ | ||
export type { MqFunctions, HandlerEvent, HandlerFunction } from './MqFunctions' | ||
declare const _default: { | ||
createMqFunctions: (query: string) => import(".").MqFunctions; | ||
addMqFunction: (mqf: import(".").MqFunctions, id: string, fn: import(".").HandlerFunction) => void; | ||
removeMqFunction: (mqf: import(".").MqFunctions, id: string) => void; | ||
runMqFunction: (mqf: import(".").MqFunctions, id: string) => void; | ||
}; | ||
export default _default; | ||
createMqFunctions: (query: string) => import('./MqFunctions').MqFunctions | ||
addMqFunction: ( | ||
mqf: import('./MqFunctions').MqFunctions, | ||
id: string, | ||
fn: import('./MqFunctions').HandlerFunction, | ||
) => void | ||
removeMqFunction: ( | ||
mqf: import('./MqFunctions').MqFunctions, | ||
id: string, | ||
) => void | ||
runMqFunction: (mqf: import('./MqFunctions').MqFunctions, id: string) => void | ||
} | ||
export default _default |
/*! | ||
Mqfunctions.js v0.1.0 | ||
Mqfunctions.js v0.1.0-alpha.2 | ||
https://github.com/kimulaco/mqfunctions | ||
@@ -7,84 +7,84 @@ Released under the MIT License. | ||
const createMqFunctions = (query) => { | ||
if (!query) { | ||
throw new Error('required query'); | ||
} | ||
const functions = new Map(); | ||
return { | ||
functions, | ||
mql: window.matchMedia(query), | ||
_handleChange: (event) => { | ||
if (functions.size <= 0) { | ||
return; | ||
} | ||
for (const [, fn] of functions) { | ||
fn(event); | ||
} | ||
}, | ||
}; | ||
}; | ||
if (!query) { | ||
throw new Error('required query') | ||
} | ||
const functions = new Map() | ||
return { | ||
functions, | ||
mql: window.matchMedia(query), | ||
_handleChange: (event) => { | ||
if (functions.size <= 0) { | ||
return | ||
} | ||
for (const [, fn] of functions) { | ||
fn(event) | ||
} | ||
}, | ||
} | ||
} | ||
const addEventListener = (mql, handler) => { | ||
if (typeof mql.addEventListener === 'function') { | ||
mql.addEventListener('change', handler); | ||
return; | ||
} | ||
// Fallback for legacy browser | ||
mql.addListener(handler); | ||
}; | ||
if (typeof mql.addEventListener === 'function') { | ||
mql.addEventListener('change', handler) | ||
return | ||
} | ||
// Fallback for legacy browser | ||
mql.addListener(handler) | ||
} | ||
const removeEventListener = (mql, handler) => { | ||
if (typeof mql.addEventListener === 'function') { | ||
mql.removeEventListener('change', handler); | ||
} | ||
// Fallback for legacy browser | ||
mql.removeListener(handler); | ||
}; | ||
if (typeof mql.addEventListener === 'function') { | ||
mql.removeEventListener('change', handler) | ||
} | ||
// Fallback for legacy browser | ||
mql.removeListener(handler) | ||
} | ||
const addMqFunction = (mqf, id, fn) => { | ||
if (!id) { | ||
throw new Error('required function id'); | ||
} | ||
if (mqf.functions.has(id)) { | ||
throw new Error(`${id} has already been added`); | ||
} | ||
mqf.functions.set(id, fn); | ||
removeEventListener(mqf.mql, mqf._handleChange.bind(mqf)); | ||
addEventListener(mqf.mql, mqf._handleChange.bind(mqf)); | ||
}; | ||
if (!id) { | ||
throw new Error('required function id') | ||
} | ||
if (mqf.functions.has(id)) { | ||
throw new Error(`${id} has already been added`) | ||
} | ||
mqf.functions.set(id, fn) | ||
removeEventListener(mqf.mql, mqf._handleChange.bind(mqf)) | ||
addEventListener(mqf.mql, mqf._handleChange.bind(mqf)) | ||
} | ||
const removeMqFunction = (mqf, id) => { | ||
if (!id) { | ||
throw new Error('required function id'); | ||
} | ||
if (!mqf.functions.has(id)) { | ||
throw new Error(`${id} does not exist`); | ||
} | ||
mqf.functions.delete(id); | ||
removeEventListener(mqf.mql, mqf._handleChange.bind(mqf)); | ||
addEventListener(mqf.mql, mqf._handleChange.bind(mqf)); | ||
}; | ||
if (!id) { | ||
throw new Error('required function id') | ||
} | ||
if (!mqf.functions.has(id)) { | ||
throw new Error(`${id} does not exist`) | ||
} | ||
mqf.functions.delete(id) | ||
removeEventListener(mqf.mql, mqf._handleChange.bind(mqf)) | ||
addEventListener(mqf.mql, mqf._handleChange.bind(mqf)) | ||
} | ||
const runMqFunction = (mqf, id) => { | ||
if (!id) { | ||
throw new Error('required function id'); | ||
if (!id) { | ||
throw new Error('required function id') | ||
} | ||
if (!mqf.functions.has(id)) { | ||
throw new Error(`${id} does not exist`) | ||
} | ||
const fn = mqf.functions.get(id) | ||
const _handleChange = (_mql) => { | ||
if (typeof fn === 'function') { | ||
fn(_mql) | ||
} | ||
if (!mqf.functions.has(id)) { | ||
throw new Error(`${id} does not exist`); | ||
} | ||
const fn = mqf.functions.get(id); | ||
const _handleChange = (_mql) => { | ||
if (typeof fn === 'function') { | ||
fn(_mql); | ||
} | ||
}; | ||
_handleChange(mqf.mql); | ||
}; | ||
} | ||
_handleChange(mqf.mql) | ||
} | ||
var index = { | ||
createMqFunctions, | ||
addMqFunction, | ||
removeMqFunction, | ||
runMqFunction, | ||
}; | ||
createMqFunctions, | ||
addMqFunction, | ||
removeMqFunction, | ||
runMqFunction, | ||
} | ||
export { index as default }; | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguZXMuanMiLCJzb3VyY2VzIjpbIi4uL3NyYy9jcmVhdGVNcUZ1bmN0aW9ucy50cyIsIi4uL3NyYy91dGlscy9ldmVudExpc3RlbmVyLnRzIiwiLi4vc3JjL2FkZE1xRnVuY3Rpb24udHMiLCIuLi9zcmMvcmVtb3ZlTXFGdW5jdGlvbi50cyIsIi4uL3NyYy9ydW5NcUZ1bmN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LGFBQWEsR0FBRyxDQUFDLEdBQWdCLEVBQUUsRUFBVSxLQUFVO0lBQ2xFLElBQUksQ0FBQyxFQUFFLEVBQUU7QUFDUCxRQUFBLE1BQU0sSUFBSSxLQUFLLENBQUMsc0JBQXNCLENBQUMsQ0FBQTtBQUN4QyxLQUFBO0lBQ0QsSUFBSSxDQUFDLEdBQUcsQ0FBQyxTQUFTLENBQUMsR0FBRyxDQUFDLEVBQUUsQ0FBQyxFQUFFO0FBQzFCLFFBQUEsTUFBTSxJQUFJLEtBQUssQ0FBQyxHQUFHLEVBQUUsQ0FBQSxlQUFBLENBQWlCLENBQUMsQ0FBQTtBQUN4QyxLQUFBO0lBRUQsTUFBTSxFQUFFLEdBQUcsR0FBRyxDQUFDLFNBQVMsQ0FBQyxHQUFHLENBQUMsRUFBRSxDQUFDLENBQUE7QUFDaEMsSUFBQSxNQUFNLGFBQWEsR0FBRyxDQUFDLElBQWtCLEtBQVU7QUFDakQsUUFBQSxJQUFJLE9BQU8sRUFBRSxLQUFLLFVBQVUsRUFBRTtZQUM1QixFQUFFLENBQUMsSUFBSSxDQUFDLENBQUE7QUFDVCxTQUFBO0FBQ0gsS0FBQyxDQUFBO0FBRUQsSUFBQSxhQUFhLENBQUMsR0FBRyxDQUFDLEdBQUcsQ0FBQyxDQUFBO0FBQ3hCLENBQUM7O0FDWEQsWUFBZTtJQUNiLGlCQUFpQjtJQUNqQixhQUFhO0lBQ2IsZ0JBQWdCO0lBQ2hCLGFBQWE7Q0FDZDs7OzsifQ== |
/*! | ||
Mqfunctions.js v0.1.0 | ||
Mqfunctions.js v0.1.0-alpha.2 | ||
https://github.com/kimulaco/mqfunctions | ||
Released under the MIT License. | ||
*/ | ||
'use strict'; | ||
'use strict' | ||
const createMqFunctions = (query) => { | ||
if (!query) { | ||
throw new Error('required query'); | ||
} | ||
const functions = new Map(); | ||
return { | ||
functions, | ||
mql: window.matchMedia(query), | ||
_handleChange: (event) => { | ||
if (functions.size <= 0) { | ||
return; | ||
} | ||
for (const [, fn] of functions) { | ||
fn(event); | ||
} | ||
}, | ||
}; | ||
}; | ||
if (!query) { | ||
throw new Error('required query') | ||
} | ||
const functions = new Map() | ||
return { | ||
functions, | ||
mql: window.matchMedia(query), | ||
_handleChange: (event) => { | ||
if (functions.size <= 0) { | ||
return | ||
} | ||
for (const [, fn] of functions) { | ||
fn(event) | ||
} | ||
}, | ||
} | ||
} | ||
const addEventListener = (mql, handler) => { | ||
if (typeof mql.addEventListener === 'function') { | ||
mql.addEventListener('change', handler); | ||
return; | ||
} | ||
// Fallback for legacy browser | ||
mql.addListener(handler); | ||
}; | ||
if (typeof mql.addEventListener === 'function') { | ||
mql.addEventListener('change', handler) | ||
return | ||
} | ||
// Fallback for legacy browser | ||
mql.addListener(handler) | ||
} | ||
const removeEventListener = (mql, handler) => { | ||
if (typeof mql.addEventListener === 'function') { | ||
mql.removeEventListener('change', handler); | ||
} | ||
// Fallback for legacy browser | ||
mql.removeListener(handler); | ||
}; | ||
if (typeof mql.addEventListener === 'function') { | ||
mql.removeEventListener('change', handler) | ||
} | ||
// Fallback for legacy browser | ||
mql.removeListener(handler) | ||
} | ||
const addMqFunction = (mqf, id, fn) => { | ||
if (!id) { | ||
throw new Error('required function id'); | ||
} | ||
if (mqf.functions.has(id)) { | ||
throw new Error(`${id} has already been added`); | ||
} | ||
mqf.functions.set(id, fn); | ||
removeEventListener(mqf.mql, mqf._handleChange.bind(mqf)); | ||
addEventListener(mqf.mql, mqf._handleChange.bind(mqf)); | ||
}; | ||
if (!id) { | ||
throw new Error('required function id') | ||
} | ||
if (mqf.functions.has(id)) { | ||
throw new Error(`${id} has already been added`) | ||
} | ||
mqf.functions.set(id, fn) | ||
removeEventListener(mqf.mql, mqf._handleChange.bind(mqf)) | ||
addEventListener(mqf.mql, mqf._handleChange.bind(mqf)) | ||
} | ||
const removeMqFunction = (mqf, id) => { | ||
if (!id) { | ||
throw new Error('required function id'); | ||
} | ||
if (!mqf.functions.has(id)) { | ||
throw new Error(`${id} does not exist`); | ||
} | ||
mqf.functions.delete(id); | ||
removeEventListener(mqf.mql, mqf._handleChange.bind(mqf)); | ||
addEventListener(mqf.mql, mqf._handleChange.bind(mqf)); | ||
}; | ||
if (!id) { | ||
throw new Error('required function id') | ||
} | ||
if (!mqf.functions.has(id)) { | ||
throw new Error(`${id} does not exist`) | ||
} | ||
mqf.functions.delete(id) | ||
removeEventListener(mqf.mql, mqf._handleChange.bind(mqf)) | ||
addEventListener(mqf.mql, mqf._handleChange.bind(mqf)) | ||
} | ||
const runMqFunction = (mqf, id) => { | ||
if (!id) { | ||
throw new Error('required function id'); | ||
if (!id) { | ||
throw new Error('required function id') | ||
} | ||
if (!mqf.functions.has(id)) { | ||
throw new Error(`${id} does not exist`) | ||
} | ||
const fn = mqf.functions.get(id) | ||
const _handleChange = (_mql) => { | ||
if (typeof fn === 'function') { | ||
fn(_mql) | ||
} | ||
if (!mqf.functions.has(id)) { | ||
throw new Error(`${id} does not exist`); | ||
} | ||
const fn = mqf.functions.get(id); | ||
const _handleChange = (_mql) => { | ||
if (typeof fn === 'function') { | ||
fn(_mql); | ||
} | ||
}; | ||
_handleChange(mqf.mql); | ||
}; | ||
} | ||
_handleChange(mqf.mql) | ||
} | ||
var index = { | ||
createMqFunctions, | ||
addMqFunction, | ||
removeMqFunction, | ||
runMqFunction, | ||
}; | ||
createMqFunctions, | ||
addMqFunction, | ||
removeMqFunction, | ||
runMqFunction, | ||
} | ||
module.exports = index; | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VzIjpbIi4uL3NyYy9jcmVhdGVNcUZ1bmN0aW9ucy50cyIsIi4uL3NyYy91dGlscy9ldmVudExpc3RlbmVyLnRzIiwiLi4vc3JjL2FkZE1xRnVuY3Rpb24udHMiLCIuLi9zcmMvcmVtb3ZlTXFGdW5jdGlvbi50cyIsIi4uL3NyYy9ydW5NcUZ1bmN0aW9uLnR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BRSxFQUFVLEtBQVU7SUFDbEUsSUFBSSxDQUFDLEVBQUUsRUFBRTtBQUNQLFFBQUEsTUFBTSxJQUFJLEtBQUssQ0FBQyxzQkFBc0IsQ0FBQyxDQUFBO0FBQ3hDLEtBQUE7SUFDRCxJQUFJLENBQUMsR0FBRyxDQUFDLFNBQVMsQ0FBQyxHQUFHLENBQUMsRUFBRSxDQUFDLEVBQUU7QUFDMUIsUUFBQSxNQUFNLElBQUksS0FBSyxDQUFDLEdBQUcsRUFBRSxDQUFBLGVBQUEsQ0FBaUIsQ0FBQyxDQUFBO0FBQ3hDLEtBQUE7SUFFRCxNQUFNLEVBQUUsR0FBRyxHQUFHLENBQUMsU0FBUyxDQUFDLEdBQUcsQ0FBQyxFQUFFLENBQUMsQ0FBQTtBQUNoQyxJQUFBLE1BQU0sYUFBYSxHQUFHLENBQUMsSUFBa0IsS0FBVTtBQUNqRCxRQUFBLElBQUksT0FBTyxFQUFFLEtBQUssVUFBVSxFQUFFO1lBQzVCLEVBQUUsQ0FBQyxJQUFJLENBQUMsQ0FBQTtBQUNULFNBQUE7QUFDSCxLQUFDLENBQUE7QUFFRCxJQUFBLGFBQWEsQ0FBQyxHQUFHLENBQUMsR0FBRyxDQUFDLENBQUE7QUFDeEIsQ0FBQzs7QUNYRCxZQUFlO0lBQ2IsaUJBQWlCO0lBQ2pCLGFBQWE7SUFDYixnQkFBZ0I7SUFDaEIsYUFBYTtDQUNkOzs7OyJ9 |
/*! | ||
Mqfunctions.js v0.1.0 | ||
Mqfunctions.js v0.1.0-alpha.2 | ||
https://github.com/kimulaco/mqfunctions | ||
@@ -7,89 +7,88 @@ Released under the MIT License. | ||
var Mqfunctions = (function () { | ||
'use strict'; | ||
'use strict' | ||
const createMqFunctions = (query) => { | ||
if (!query) { | ||
throw new Error('required query'); | ||
const createMqFunctions = (query) => { | ||
if (!query) { | ||
throw new Error('required query') | ||
} | ||
const functions = new Map() | ||
return { | ||
functions, | ||
mql: window.matchMedia(query), | ||
_handleChange: (event) => { | ||
if (functions.size <= 0) { | ||
return | ||
} | ||
const functions = new Map(); | ||
return { | ||
functions, | ||
mql: window.matchMedia(query), | ||
_handleChange: (event) => { | ||
if (functions.size <= 0) { | ||
return; | ||
} | ||
for (const [, fn] of functions) { | ||
fn(event); | ||
} | ||
}, | ||
}; | ||
}; | ||
const addEventListener = (mql, handler) => { | ||
if (typeof mql.addEventListener === 'function') { | ||
mql.addEventListener('change', handler); | ||
return; | ||
for (const [, fn] of functions) { | ||
fn(event) | ||
} | ||
// Fallback for legacy browser | ||
mql.addListener(handler); | ||
}; | ||
const removeEventListener = (mql, handler) => { | ||
if (typeof mql.addEventListener === 'function') { | ||
mql.removeEventListener('change', handler); | ||
} | ||
// Fallback for legacy browser | ||
mql.removeListener(handler); | ||
}; | ||
}, | ||
} | ||
} | ||
const addMqFunction = (mqf, id, fn) => { | ||
if (!id) { | ||
throw new Error('required function id'); | ||
} | ||
if (mqf.functions.has(id)) { | ||
throw new Error(`${id} has already been added`); | ||
} | ||
mqf.functions.set(id, fn); | ||
removeEventListener(mqf.mql, mqf._handleChange.bind(mqf)); | ||
addEventListener(mqf.mql, mqf._handleChange.bind(mqf)); | ||
}; | ||
const addEventListener = (mql, handler) => { | ||
if (typeof mql.addEventListener === 'function') { | ||
mql.addEventListener('change', handler) | ||
return | ||
} | ||
// Fallback for legacy browser | ||
mql.addListener(handler) | ||
} | ||
const removeEventListener = (mql, handler) => { | ||
if (typeof mql.addEventListener === 'function') { | ||
mql.removeEventListener('change', handler) | ||
} | ||
// Fallback for legacy browser | ||
mql.removeListener(handler) | ||
} | ||
const removeMqFunction = (mqf, id) => { | ||
if (!id) { | ||
throw new Error('required function id'); | ||
} | ||
if (!mqf.functions.has(id)) { | ||
throw new Error(`${id} does not exist`); | ||
} | ||
mqf.functions.delete(id); | ||
removeEventListener(mqf.mql, mqf._handleChange.bind(mqf)); | ||
addEventListener(mqf.mql, mqf._handleChange.bind(mqf)); | ||
}; | ||
const addMqFunction = (mqf, id, fn) => { | ||
if (!id) { | ||
throw new Error('required function id') | ||
} | ||
if (mqf.functions.has(id)) { | ||
throw new Error(`${id} has already been added`) | ||
} | ||
mqf.functions.set(id, fn) | ||
removeEventListener(mqf.mql, mqf._handleChange.bind(mqf)) | ||
addEventListener(mqf.mql, mqf._handleChange.bind(mqf)) | ||
} | ||
const runMqFunction = (mqf, id) => { | ||
if (!id) { | ||
throw new Error('required function id'); | ||
} | ||
if (!mqf.functions.has(id)) { | ||
throw new Error(`${id} does not exist`); | ||
} | ||
const fn = mqf.functions.get(id); | ||
const _handleChange = (_mql) => { | ||
if (typeof fn === 'function') { | ||
fn(_mql); | ||
} | ||
}; | ||
_handleChange(mqf.mql); | ||
}; | ||
const removeMqFunction = (mqf, id) => { | ||
if (!id) { | ||
throw new Error('required function id') | ||
} | ||
if (!mqf.functions.has(id)) { | ||
throw new Error(`${id} does not exist`) | ||
} | ||
mqf.functions.delete(id) | ||
removeEventListener(mqf.mql, mqf._handleChange.bind(mqf)) | ||
addEventListener(mqf.mql, mqf._handleChange.bind(mqf)) | ||
} | ||
var index = { | ||
createMqFunctions, | ||
addMqFunction, | ||
removeMqFunction, | ||
runMqFunction, | ||
}; | ||
const runMqFunction = (mqf, id) => { | ||
if (!id) { | ||
throw new Error('required function id') | ||
} | ||
if (!mqf.functions.has(id)) { | ||
throw new Error(`${id} does not exist`) | ||
} | ||
const fn = mqf.functions.get(id) | ||
const _handleChange = (_mql) => { | ||
if (typeof fn === 'function') { | ||
fn(_mql) | ||
} | ||
} | ||
_handleChange(mqf.mql) | ||
} | ||
return index; | ||
var index = { | ||
createMqFunctions, | ||
addMqFunction, | ||
removeMqFunction, | ||
runMqFunction, | ||
} | ||
})(); | ||
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibXFmdW5jdGlvbnMuanMiLCJzb3VyY2VzIjpbIi4uL3NyYy9jcmVhdGVNcUZ1bmN0aW9ucy50cyIsIi4uL3NyY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||
*/ | ||
var Mqfunctions=function(){"use strict";const n=(n,e)=>{"function"!=typeof n.addEventListener?n.addListener(e):n.addEventListener("change",e)},e=(n,e)=>{"function"==typeof n.addEventListener&&n.removeEventListener("change",e),n.removeListener(e)};return{createMqFunctions:n=>{if(!n)throw new Error("required query");const e=new Map;return{functions:e,mql:window.matchMedia(n),_handleChange:n=>{if(!(e.size<=0))for(const[,r]of e)r(n)}}},addMqFunction:(r,t,i)=>{if(!t)throw new Error("required function id");if(r.functions.has(t))throw new Error(`${t} has already been added`);r.functions.set(t,i),e(r.mql,r._handleChange.bind(r)),n(r.mql,r._handleChange.bind(r))},removeMqFunction:(r,t)=>{if(!t)throw new Error("required function id");if(!r.functions.has(t))throw new Error(`${t} does not exist`);r.functions.delete(t),e(r.mql,r._handleChange.bind(r)),n(r.mql,r._handleChange.bind(r))},runMqFunction:(n,e)=>{if(!e)throw new Error("required function id");if(!n.functions.has(e))throw new Error(`${e} does not exist`);const r=n.functions.get(e);var t;t=n.mql,"function"==typeof r&&r(t)}}}(); | ||
var Mqfunctions = (function () { | ||
'use strict' | ||
const n = (n, e) => { | ||
'function' != typeof n.addEventListener | ||
? n.addListener(e) | ||
: n.addEventListener('change', e) | ||
}, | ||
e = (n, e) => { | ||
'function' == typeof n.addEventListener && | ||
n.removeEventListener('change', e), | ||
n.removeListener(e) | ||
} | ||
return { | ||
createMqFunctions: (n) => { | ||
if (!n) throw new Error('required query') | ||
const e = new Map() | ||
return { | ||
functions: e, | ||
mql: window.matchMedia(n), | ||
_handleChange: (n) => { | ||
if (!(e.size <= 0)) for (const [, r] of e) r(n) | ||
}, | ||
} | ||
}, | ||
addMqFunction: (r, t, i) => { | ||
if (!t) throw new Error('required function id') | ||
if (r.functions.has(t)) throw new Error(`${t} has already been added`) | ||
r.functions.set(t, i), | ||
e(r.mql, r._handleChange.bind(r)), | ||
n(r.mql, r._handleChange.bind(r)) | ||
}, | ||
removeMqFunction: (r, t) => { | ||
if (!t) throw new Error('required function id') | ||
if (!r.functions.has(t)) throw new Error(`${t} does not exist`) | ||
r.functions.delete(t), | ||
e(r.mql, r._handleChange.bind(r)), | ||
n(r.mql, r._handleChange.bind(r)) | ||
}, | ||
runMqFunction: (n, e) => { | ||
if (!e) throw new Error('required function id') | ||
if (!n.functions.has(e)) throw new Error(`${e} does not exist`) | ||
const r = n.functions.get(e) | ||
var t | ||
;(t = n.mql), 'function' == typeof r && r(t) | ||
}, | ||
} | ||
})() |
@@ -1,2 +0,2 @@ | ||
import type { MqFunctions } from './index.d'; | ||
export declare const removeMqFunction: (mqf: MqFunctions, id: string) => void; | ||
import type { MqFunctions } from './MqFunctions' | ||
export declare const removeMqFunction: (mqf: MqFunctions, id: string) => void |
@@ -1,2 +0,2 @@ | ||
import type { MqFunctions } from './index.d'; | ||
export declare const runMqFunction: (mqf: MqFunctions, id: string) => void; | ||
import type { MqFunctions } from './MqFunctions' | ||
export declare const runMqFunction: (mqf: MqFunctions, id: string) => void |
@@ -1,2 +0,8 @@ | ||
export declare const addEventListener: (mql: MediaQueryList, handler: (event: MediaQueryListEvent) => void) => void; | ||
export declare const removeEventListener: (mql: MediaQueryList, handler: (event: MediaQueryListEvent) => void) => void; | ||
export declare const addEventListener: ( | ||
mql: MediaQueryList, | ||
handler: (event: MediaQueryListEvent) => void, | ||
) => void | ||
export declare const removeEventListener: ( | ||
mql: MediaQueryList, | ||
handler: (event: MediaQueryListEvent) => void, | ||
) => void |
{ | ||
"name": "mqfunctions", | ||
"version": "0.1.0-alpha.1", | ||
"version": "0.1.0-alpha.2", | ||
"description": "JavaScript library to manage matchMedia handlers.", | ||
@@ -21,3 +21,3 @@ "keywords": [ | ||
"main": "dist/index.js", | ||
"types": "types/index.d.ts", | ||
"types": "dist/index.d.ts", | ||
"module": "dist/index.es.js", | ||
@@ -40,2 +40,3 @@ "browser": "dist/mqfunctions.js", | ||
"test:e2e": "jest -c jest.e2e.config.js --verbose", | ||
"pretest:e2e": "node scripts/setupE2E.js", | ||
"test:serve": "serve test/fixtures -p 3000" | ||
@@ -42,0 +43,0 @@ }, |
@@ -5,2 +5,3 @@ # mqfunctions | ||
[![License MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT) | ||
[![npm version](https://badge.fury.io/js/mqfunctions.svg)](https://badge.fury.io/js/mqfunctions) | ||
@@ -7,0 +8,0 @@ JavaScript library to manage matchMedia handlers. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
37663
14
443
46
1