store.ts without dependencies

pull/2832/head
Sander Hahn 6 years ago
parent d548a5a5f4
commit ed9a32fd7d

@ -94,26 +94,21 @@ export default [
{
file: `store.mjs`,
format: 'esm',
paths: id => id.startsWith('svelte/') && id.replace('svelte', '.')
},
{
file: `store.js`,
format: 'cjs',
paths: id => id.startsWith('svelte/') && id.replace('svelte', '.')
}
],
plugins: [
is_publish
? typescript({
include: 'src/**',
exclude: 'src/internal/**',
typescript: require('typescript')
})
: sucrase({
transforms: ['typescript']
})
],
external: id => id.startsWith('svelte/')
]
},
// everything else

@ -1,4 +1,10 @@
import { run_all, noop, safe_not_equal, is_function } from './internal/utils';
/** Safe not equal. */
function safe_not_equal(a: any, b: any) {
return a !== a ? b === b : a !== b || ((a && typeof a === 'object') || typeof a === 'function');
}
/** No operation. */
function noop() { }
/** Callback to inform of a value updates. */
type Subscriber<T> = (value: T) => void;
@ -143,7 +149,7 @@ export function derived<T, S extends Stores>(
if (auto) {
set(result as T);
} else {
cleanup = is_function(result) ? result as Unsubscriber : noop;
cleanup = result instanceof Function ? result as Unsubscriber : noop;
}
};
@ -164,7 +170,7 @@ export function derived<T, S extends Stores>(
sync();
return function stop() {
run_all(unsubscribers);
unsubscribers.forEach((unsubscribe) => unsubscribe());
cleanup();
};
});

Loading…
Cancel
Save