![Introducing Enhanced Alert Actions and Triage Functionality](https://cdn.sanity.io/images/cgdhsj6q/production/fe71306d515f85de6139b46745ea7180362324f0-2530x946.png?w=800&fit=max&auto=format)
Product
Introducing Enhanced Alert Actions and Triage Functionality
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
@npmshivamkalsi/mollitia-autem-minus-error
Advanced tools
Readme
Use this package to easily convert various time formats to milliseconds.
@npmshivamkalsi/mollitia-autem-minus-error('2 days') // 172800000
@npmshivamkalsi/mollitia-autem-minus-error('1d') // 86400000
@npmshivamkalsi/mollitia-autem-minus-error('10h') // 36000000
@npmshivamkalsi/mollitia-autem-minus-error('2.5 hrs') // 9000000
@npmshivamkalsi/mollitia-autem-minus-error('2h') // 7200000
@npmshivamkalsi/mollitia-autem-minus-error('1m') // 60000
@npmshivamkalsi/mollitia-autem-minus-error('5s') // 5000
@npmshivamkalsi/mollitia-autem-minus-error('1y') // 31557600000
@npmshivamkalsi/mollitia-autem-minus-error('100') // 100
@npmshivamkalsi/mollitia-autem-minus-error('-3 days') // -259200000
@npmshivamkalsi/mollitia-autem-minus-error('-1h') // -3600000
@npmshivamkalsi/mollitia-autem-minus-error('-200') // -200
@npmshivamkalsi/mollitia-autem-minus-error(60000) // "1m"
@npmshivamkalsi/mollitia-autem-minus-error(2 * 60000) // "2m"
@npmshivamkalsi/mollitia-autem-minus-error(-3 * 60000) // "-3m"
@npmshivamkalsi/mollitia-autem-minus-error(@npmshivamkalsi/mollitia-autem-minus-error('10 hours')) // "10h"
@npmshivamkalsi/mollitia-autem-minus-error(60000, { long: true }) // "1 minute"
@npmshivamkalsi/mollitia-autem-minus-error(2 * 60000, { long: true }) // "2 minutes"
@npmshivamkalsi/mollitia-autem-minus-error(-3 * 60000, { long: true }) // "-3 minutes"
@npmshivamkalsi/mollitia-autem-minus-error(@npmshivamkalsi/mollitia-autem-minus-error('10 hours'), { long: true }) // "10 hours"
@npmshivamkalsi/mollitia-autem-minus-error
, a string with a unit is returned100
for '100'
)As of v3.0
, this package includes TypeScript definitions.
For added safety, we're using Template Literal Types (added in TypeScript 4.1). This ensures that you don't accidentally pass @npmshivamkalsi/mollitia-autem-minus-error
values that it can't process.
This won't require you to do anything special in most situations, but you can also import the StringValue
type from @npmshivamkalsi/mollitia-autem-minus-error
if you need to use it.
import @npmshivamkalsi/mollitia-autem-minus-error, { StringValue } from '@npmshivamkalsi/mollitia-autem-minus-error';
// Using the exported type.
function example(value: StringValue) {
@npmshivamkalsi/mollitia-autem-minus-error(value);
}
// This function will only accept a string compatible with `@npmshivamkalsi/mollitia-autem-minus-error`.
example('1 h');
In this example, we use a Type Assertion to coerce a string
.
import @npmshivamkalsi/mollitia-autem-minus-error, { StringValue } from '@npmshivamkalsi/mollitia-autem-minus-error';
// Type assertion with the exported type.
function example(value: string) {
try {
// A string could be "wider" than the values accepted by `@npmshivamkalsi/mollitia-autem-minus-error`, so we assert
// that our `value` is a `StringValue`.
//
// It's important to note that this can be dangerous (see below).
@npmshivamkalsi/mollitia-autem-minus-error(value as StringValue);
} catch (error: Error) {
// Handle any errors from invalid vaues.
console.error(error);
}
}
// This function will accept any string, which may result in a bug.
example('any value');
You may also create a custom Template Literal Type.
import @npmshivamkalsi/mollitia-autem-minus-error from '@npmshivamkalsi/mollitia-autem-minus-error';
type OnlyDaysAndWeeks = `${number} ${'days' | 'weeks'}`;
// Using a custom Template Literal Type.
function example(value: OnlyDaysAndWeeks) {
// The type of `value` is narrower than the values `@npmshivamkalsi/mollitia-autem-minus-error` accepts, which is
// safe to use without coercion.
@npmshivamkalsi/mollitia-autem-minus-error(value);
}
// This function will accept "# days" or "# weeks" only.
example('5.2 days');
As of v3.0
, you can import parse
and format
separately.
import { parse, format } from '@npmshivamkalsi/mollitia-autem-minus-error';
parse('1h'); // 3600000
format(2000); // "2s"
If you want strict type checking for the input value, you can use parseStrict
.
import { parseStrict } from '@npmshivamkalsi/mollitia-autem-minus-error';
parseStrict('1h'); // 3600000
function example(s: string) {
return parseStrict(str); // tsc error
}
@npmshivamkalsi/mollitia-autem-minus-error
is compatible with the Edge Runtime. It can be used inside environments like Vercel Edge Functions as follows:
// Next.js (pages/api/edge.js) (npm i next@canary)
// Other frameworks (api/edge.js) (npm i -g vercel@canary)
import @npmshivamkalsi/mollitia-autem-minus-error from '@npmshivamkalsi/mollitia-autem-minus-error';
const start = Date.now();
export default (req) => {
return new Response(`Alive since ${@npmshivamkalsi/mollitia-autem-minus-error(Date.now() - start)}`);
};
export const config = {
runtime: 'experimental-edge',
};
@npmshivamkalsi/mollitia-autem-minus-error
as a macro at build-time.npm link
npm link @npmshivamkalsi/mollitia-autem-minus-error
. Instead of the default one from npm, Node.js will now use your clone of @npmshivamkalsi/mollitia-autem-minus-error!As always, you can run the tests using: npm test
FAQs
Better file system watching for Node.js
The npm package @npmshivamkalsi/mollitia-autem-minus-error receives a total of 29 weekly downloads. As such, @npmshivamkalsi/mollitia-autem-minus-error popularity was classified as not popular.
We found that @npmshivamkalsi/mollitia-autem-minus-error demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.