From 80a998eedba54d120e9ed6a38ad2be8aa4981f6e Mon Sep 17 00:00:00 2001 From: ApteryxXYZ Date: Thu, 22 Sep 2022 18:56:28 +1200 Subject: [PATCH] chore: update examples --- examples/browser.html | 86 ++++++++++++++++++---------------- examples/node.cjs | 23 +++++++++ examples/{node.js => node.mjs} | 3 +- examples/node.ts | 3 +- 4 files changed, 73 insertions(+), 42 deletions(-) create mode 100644 examples/node.cjs rename examples/{node.js => node.mjs} (93%) diff --git a/examples/browser.html b/examples/browser.html index bef5002..d4a52f4 100644 --- a/examples/browser.html +++ b/examples/browser.html @@ -1,40 +1,46 @@ - - - - - - - JSWhat Browser Example - - - - - -

Type something into the text input below and press 'WHAT?'

- - -
-
- - - + + + + + + + + JSWhat Browser Example + + + + + + + + +

Type something into the text input below and press 'WHAT?!'

+ + +

+ + + + \ No newline at end of file diff --git a/examples/node.cjs b/examples/node.cjs new file mode 100644 index 0000000..969040c --- /dev/null +++ b/examples/node.cjs @@ -0,0 +1,23 @@ +const what = require('..'); +// const what = require('jswhat'); + +// General usage +const match = what.is('fake@mail.com')[0]; +console.log('Simply match an email only\n', match.matched); + +// Search with a string +var matches = what.is('hot@mail.com g@mail.com e@mail.com', { search: true }); +const sMatched = matches.map((m) => m.matched); +console.log('\nFind every possible match within\n', sMatched.join(', ')); + +// Filter the output by a name, short name, category or tag +const fOptions = { search: true, filter: ['Email'] }; +const filtered = what.is('fake@mail.com g@mail.com e@mail.com', fOptions); +const fMatched = filtered.map((m) => m.matched); +console.log('\nOnly match possible email addresses\n', fMatched.join(', ')); + +// Exclude a name, short name, category or tag +const eOptions = { search: true, exclude: ['URL', 'YouTube'] }; +const excluded = what.is('hot@mail.com g@mail.com https://youtube.com/pewdiepie', eOptions); +const eMatched = excluded.map((m) => m.matched); +console.log('\nExclude a property from the results, in this case URLs and YouTube related\n', eMatched.join(', ')); diff --git a/examples/node.js b/examples/node.mjs similarity index 93% rename from examples/node.js rename to examples/node.mjs index f59e091..4799aa6 100644 --- a/examples/node.js +++ b/examples/node.mjs @@ -1,4 +1,5 @@ -const what = require('../'); +import what from '..'; +// import what from 'jswhat'; // General usage const match = what.is('fake@mail.com')[0]; diff --git a/examples/node.ts b/examples/node.ts index 7124553..89b7943 100644 --- a/examples/node.ts +++ b/examples/node.ts @@ -1,4 +1,5 @@ -import * as what from '../'; +import what from '..'; +// import what from 'jswhat'; // General usage const match = what.is('fake@mail.com')[0];