New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ng-server-time

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ng-server-time - npm Package Compare versions

Comparing version 1.0.1 to 1.0.2

ng-server-time-factory.min.js

4

package.json
{
"name": "ng-server-time",
"version": "1.0.1",
"version": "1.0.2",
"description": "Angular web socket implementation of network time protocol",
"main": "ng-server-time.js",
"main": "server-time-socket.js",
"scripts": {

@@ -7,0 +7,0 @@ "test": "echo \"Error: no test specified\" && exit 1",

@@ -1,11 +0,55 @@

Synchronizes local system time with server time
Synchronizes local browser time with server time
using clock synchronization algorithm, similar to
NTP.
##Usage
##Installation
1. Ensure angular and sockets are installed correctly
2. Ensure you have a socket factory such as [this one](https://gist.github.com/mfbx9da4/41df3703432c582f920a)
3. Include `ng-server-time-factory.js`.
4. Import `server-time-socket.js` on the server
1. Ensure angular, socket.io and ng-server-time are installed correctly
```
npm install socket.io
npm install angular
npm install ng-server-time
```
2. Ensure you have an angular socket.io factory such as this one, it is required by the server time factory:
```js
app.factory('socket', function() {
var socket = io.connect();
return socket;
});
```
3. Include `ng-server-time-factory.min.js`:
```html
<script src="/socket.io.js"></script>
<script src="/angular.min.js"></script>
<script src="/ng-server-time-factory.min.js"></script>
<script src="/my-angular-app.js"></script>
```
4. Initilaize the socket on the server:
```js
var server_time = require('ng-server-time');
io.sockets.on('connection', function (socket) {
server_time.init(socket);
});
```
###Usage
```js
app.controller('MainController', function($scope, ServerTime){
// Date.now() on the server
$scope.now = ServerTime.now();
// new Date() on the server
$scope.new = ServerTime.new();
// get offset in milliseconds between current browser
// time and server time
$scope.getOffset = ServerTime.getOffset();
});
```

@@ -1,3 +0,2 @@

module.exports = function(socket){
module.exports.init = function(socket){
socket.on('server time',function(client_now){

@@ -4,0 +3,0 @@ socket.emit('server time', {sender_transmission_time: client_now,

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc