Nutritious Pomegranate Muffins
Miss any of our Open RFC calls?Watch the recordings here! »

null-safety

1.0.0 • Public • Published

null-safety

CircleCI Coverage Status

example:

const html = `
<html>
  <h1>this is a title</h1>
</html>
`;
 
const doc = new JSDOM(html).window.document;
 
const title = NullSafety.start(doc)
  .next(o => o.querySelector('h1'))
  .next(o => o.textContent)
  .resultAlty('title-for-failed');
 
console.log(title);
// output: this is a title

type-safety:

const title = NullSafety.start(doc)
 
  .next(o => o.querySelector('h1'))
  // return: HTMLHeadingElement | null
 
  .next(o => o.textContent)
  // argument: HTMLHeadingElement (not nullable *>_<)b!
  // return:   string | null
 
  .resultAlty('title-for-failed');
  // return: string (not nullable *>_<)b!

recommendation:

Use TypeScript & TypeScript compiler option: strictNullChecks(or strict)

{
  "compilerOptions": {
    "strictNullChecks": true,
  }
}
 
// or
 
{
  "compilerOptions": {
    "strict": true,
  }
}

Install

npm i null-safety

DownloadsWeekly Downloads

3

Version

1.0.0

License

MIT

Unpacked Size

46.5 kB

Total Files

22

Last publish

Collaborators

  • avatar