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

fi-rut

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fi-rut - npm Package Compare versions

Comparing version 1.1.2 to 1.2.0

12

lib/index.js

@@ -18,5 +18,5 @@ "use strict";

function clean(value, parts) {
value = String(value).replace(CLEAN_REGEX, EMPTY);
var verifier = value.substr(-1, 1);
var digits = value.substr(0, value.length - 1).replace(DIGITS_REGEX, EMPTY);
value = (value + "").replace(CLEAN_REGEX, EMPTY);
var verifier = value.substr(-1, 1).toLowerCase();
var digits = value.substr(0, value.length - 1).replace(DIGITS_REGEX, EMPTY).toLowerCase();
if (parts) {

@@ -35,3 +35,3 @@ return [ digits, verifier ];

parts[0] = parts[0].replace(GROUP_REGEX, GROUP_REPLACE);
return parts.join(DASH);
return parts.join(DASH).toLowerCase();
}

@@ -49,7 +49,7 @@

}
return r ? String(r - 1) : K;
return r ? r - 1 + "" : K;
}
function validate(value) {
if (!value || !String(value).length) {
if (!value || !(value + "").length) {
return false;

@@ -56,0 +56,0 @@ }

@@ -5,3 +5,3 @@ {

"main": "lib/index.js",
"version": "1.1.2",
"version": "1.2.0",
"directories": {

@@ -8,0 +8,0 @@ "test": "test"

@@ -5,3 +5,3 @@ # fi-rut [![Build Status](https://travis-ci.org/FinalDevStudio/fi-rut.svg?branch=master)](https://travis-ci.org/FinalDevStudio/fi-rut)

## For the browser and AngularJS
## Browser

@@ -16,19 +16,134 @@ ### Installation

For browser development, include `dist/fi-rut.js` in your bundle or assets. For AngularJs development include `fi-rut-ng.js` as it bundles both the browser and AngularJS modules.
Include the distributable versions into your scripts bundle or load them as scripts in your HTML.
For production use the minified version of either one (`fi-rut.min.js` or `fi-rut-ng.min.js`).
The library will be assigned as `rut` into the `window` so you can access its methods directly via `window.rut`.
#### Important
**IMPORTANT:** Values will allways be converted to lower case to enforce consistency.
With both versions the module will be assigned as `rut` into the `window` so you can access its methods directly via `window.rut`.
#### Development / Debugging
#### Important for AngularJS
For production use the non-minified version:
```html
<script src="/bower_components/fi-rut/dist/fi-rut.js"></script>
```
#### Production
For production use the minified version:
```html
<script src="/bower_components/fi-rut/dist/fi-rut.min.js"></script>
```
#### Examples
```javascript
var input = document.querySelector('input#rut');
var calculated = rut.calculate(input.value);
var verififer = rut.verifier(input.value);
var isValid = rut.validate(input.value);
var formatted = rut.format(input.value);
var digits = rut.digits(input.value);
var clean = rut.clean(input.value);
```
### Documentation
Read the [library docs](docs/lib.md) for the library's methods specification.
## AngularJS
### Installation
```sh
bower install --save fi-rut
```
### Usage
Include the distributable versions into your scripts bundle or load them as scripts in your HTML.
This version includes both the browser and AngularJS modules.
The library will be assigned as `rut` into the `window` so you can access its methods directly via `window.rut`.
#### Development / Debugging
For development or easy debugging use the non-minified version:
```html
<script src="/bower_components/fi-rut/dist/fi-rut-ng.js"></script>
```
#### Production
For production use the minified version:
```html
<script src="/bower_components/fi-rut/dist/fi-rut-ng.min.js"></script>
```
#### Examples
Include the `ngRut` dependency into your app:
```javascript
angular.module('MyApp', [
// ...
'ngRut'
// ...
]);
```
##### Directive
The `ng-rut` directive must be used only in an `<input>` element and will add real-time format and validation to the associated `ngModel`:
```html
<input ng-model="data.rut" ng-rut>
```
##### Service
Use the `ngRut` service to access the module's methods programatically:
```javascript
function MyController($scope, ngRut) {
var calculated = ngRut.calculate($scope.data.rut);
var verififer = ngRut.verifier($scope.data.rut);
var isValid = ngRut.validate($scope.data.rut);
var formatted = ngRut.format($scope.data.rut);
var digits = ngRut.digits($scope.data.rut);
var clean = ngRut.clean($scope.data.rut);
}
angular.module('MyApp').controller('MyController', ['$scope', 'ngRut', MyController]);
```
##### Filter
Use the `ngRut` filter to interpolate template strings:
```html
<p>{{ data.rut | ngRut }}</p>
<p>{{ data.rut | ngRut : 'calculate' }}</p>
<p>{{ data.rut | ngRut : 'validate' }}</p>
<p>{{ data.rut | ngRut : 'verifier' }}</p>
<p>{{ data.rut | ngRut : 'digits' }}</p>
<p>{{ data.rut | ngRut : 'clean' }}</p>
```
#### Note
The module, filter, directive and service are called `ngRut` (not `fi-rut`) to maintain compatibility with the deprecated [ngRut](https://github.com/FinalDevStudio/ng-rut) module.
### Documentation
Read the [library docs](docs/lib.md) for the methods specification.
Read the [AngularJS docs](docs/angular.md) for usage and specification on the modules.
Read the [library docs](docs/lib.md) for the library's methods specification.
Read the [AngularJS docs](docs/angular.md) for usage and specification on the module, service, directive and filter.
## For Node.js

@@ -39,3 +154,3 @@

```sh
bower install --save fi-rut
npm install --save fi-rut
```

@@ -51,4 +166,19 @@

### Examples
```javascript
const rut = require('fi-rut');
var value = '22222222';
var calculated = rut.calculate(value);
var verififer = rut.verifier(value);
var isValid = rut.validate(value);
var formatted = rut.format(value);
var digits = rut.digits(value);
var clean = rut.clean(value);
```
### Documentation
Read the [library docs](docs/lib.md) for the methods specification.
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