1.0.1 • Published 6 years ago

date.id v1.0.1

Weekly downloads
4
License
MIT
Repository
github
Last release
6 years ago

Date.ID

Preview

Date.ID is a module used for generating unique IDs. This module bases it's ID generation upon the Date.now().

Installation

You can install this with any node package managers.

Install with NPM
npm i -S date.id
Install with yarn
yarn add date.id
Install with bower
bower install date.id

How to use it?

This module is possible to use both in the browser and in node.js, for the browser tutorial please refer to the Browser Tutorial, or if you're going to use this in node.js please refer to the Node.js Tutorial.

How to use it in the browser

First step is to add it into your html page.

<script src="https://cdn.rawgit.com/ihack2712/date.id/master/src/index.js" type="text/javascript"></script>

Date.id is imported into the window object as did

Here's some example usage.

<html>
	<head>
		<meta charset="UTF-8" />
		<title>Date.ID Example</title>
	</head>
	<body>
		<p id="output" style="font-family:monospace">Hey, press the cool button below that says "Generate" to generate a random DateID.</p>
		<br />
		<input type="button" id="generate" value="Generate" />
		<script src="https://cdn.rawgit.com/ihack2712/date.id/master/src/index.js" type="text/javascript"></script>
		<script type="text/javascript">
			const button = document.getElementById('generate');
			const output = document.getElementById('output');
			
			button.onclick = function (event) {
				const randomID = did();
				const message = 'Hey, I generated a random id! Look: <br />' + randomID + '<br /> Why don\'t you press the button again to make a new ID?';
				output.innerHTML = message;
			};
		</script>
	</body>
</html>

How to use it in nodejs

First step is to install the module.

Then import it into node.js by using the require function:

// Dependencies
// ...
const did = require('date.id');

Then you can use it for something:

var NewUser = {
	id: did();
	// ...
}

License

MIT License

Copyright (c) 2018 Richard Olsen Sandberg (ihack2712) ihack@theteamcoders.com

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.