
Security News
Feross on the 10 Minutes or Less Podcast: Nobody Reads the Code
Socket CEO Feross Aboukhadijeh joins 10 Minutes or Less, a podcast by Ali Rohde, to discuss the recent surge in open source supply chain attacks.
cutwater-core
Advanced tools
A library providing the functionality that we always seem to need in every Typescript/Javascript project.
A library providing the functionality that we always seem to need in every Typescript/Javascript project.
Via npm:
npm install cutwater-core
Via yarn:
yarn add cutwater-core
import { Config } from 'cutwater-core';
const url = Config.get('API_URL', 'https://api.example.com');
// Returns 'https://api.example.com' if there is no value for API_URL
const otherUrl = Config.getRequired('API_URL', 'API_URL is required!');
// Will throw an error (optionally with the provided message) if API_URL does not exist
Config.put('BACKUP_API_URL', 'https://api-backup.example.com');
import { Env } from 'cutwater-core';
if (Env.isProd()) {
console.log('Yeah, we made it to production!');
}
if (Env.isDev()) {
console.log('Not yet I guess.');
}
import { contains, startWith, endsWith } from 'cutwater-core';
if (contains('Check This', 'This')) {
console.log('Yes, it contains it.');
}
if (startsWith('x-forward', 'x-')) {
console.log('A custom header.');
}
if (endsWith('x-Forward-Cookies', 'cookies', true)) {
console.log('Case insensitivity FTW.');
}
import { TimeUnit, TZUtils } from 'cutwater-core';
const oneDayInSeconds = TimeUnit.days(1).toSeconds();
const fiveMinutesInMillis = TimeUnit.minutes(5).toMillis();
console.log(TZUtils.timestamp());
// 2018-10-06 15:22:12,345 (This is UTC)
TZUtils.timezoneOffset = TimeUnit.hours(-5).toMinutes();
console.log(TZUtils.timestamp());
// 2018-10-06 10:22:12,345 (Now we get the time in Ecuador, UTC-5)
const localizedDate = TZUtils.now();
// localizedDate is the current date/time based on the timezoneOffset, Ecuador in this case.
import { LoggerFactory } from 'cutwater-core';
const LOG = LoggerFactory.getLogger();
LOG.info('Hey, here is a log message.');
LOG.debug('Examine this object: %j', someObj);
Note: The http related functions are designed to simplify aspects of working with the http module in Node.js
import { isResponseOk, LoggerFactory, mergeHeaders, toBodyText } from 'cutwater-core';
const LOG = LoggerFactory.getLogger();
const response = magicalHttpRequestFunction();
if(isResponseOk(response)){
toBodyText(response).then(
bodyTxt => {
LOG.info('The body text was: %s', bodyTxt);
}
).catch(
err => {
LOG.error('Oops! Problem reading the body: %j',err);
}
)
const nextRequestHeaders = mergeHeaders(response.headers,{'x-custom-header':'Custom Value'},true);
// Will add the 'x-custom-header' to the received headers, or overwrite if it already exists.
}
FAQs
A library providing the functionality that we always seem to need in every Typescript/Javascript project.
The npm package cutwater-core receives a total of 8 weekly downloads. As such, cutwater-core popularity was classified as not popular.
We found that cutwater-core demonstrated a not healthy version release cadence and project activity because the last version was released 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.

Security News
Socket CEO Feross Aboukhadijeh joins 10 Minutes or Less, a podcast by Ali Rohde, to discuss the recent surge in open source supply chain attacks.

Research
/Security News
Campaign of 108 extensions harvests identities, steals sessions, and adds backdoors to browsers, all tied to the same C2 infrastructure.

Security News
OpenAI rotated macOS signing certificates after a malicious Axios package reached its CI pipeline in a broader software supply chain attack.