Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
ng2-truncate
Advanced tools
This project is a Angular 2 pipe to truncate text to a set of characters or words.
This project is a Angular 2 pipe to truncate text to a set of characters or words.
To install this library, run:
$ npm install ng2-truncate --save
Add the following line to your angular-cli-build.js
file
module.exports = function(defaults) {
return new Angular2App(defaults, {
vendorNpmFiles: [
...
'ng2-truncate/dist/**/*.+(js|js.map)',
...
]
});
};
Click here to see an example.
Then you should update your system-config.ts to map ng2-truncate
const map: any = {
'ng2-truncate': 'vendor/ng2-truncate/dist'
};
/** User packages configuration. */
const packages: any = {
'ng2-truncate': {
main: 'index'
}
};
If you are using SystemJS by your own, you should update your config files like in this example.
By default, the pipe will truncate text after 40 characters. You could override this using the first argument:
import { Component } from '@angular/core';
import { TRUNCATE_PIPES } from 'ng2-truncate';
@Component({
selector: 'my-component',
template: '<p>{{ "123456789" | truncate : 3 }}</p>',
pipes: [TRUNCATE_PIPES]
})
export class MyComponent {
}
This will produce the following html
<p>123…</p>
There is a second argument which allow to override the suffix used:
@Component({
...
template: '<p>{{ "123456789" | truncate : 3 : "xxx" }}</p>',
...
})
This will produce the following html
<p>123xxx</p>
You can also truncate left side by using negative limit
@Component({
...
template: '<p>{{ "123456789" | truncate : -4 : "…" }}</p>',
...
})
This will produce the following html
<p>…6789</p>
Using TRUNCATE_PIPES also enable truncating by words
import { Component } from '@angular/core';
import { TRUNCATE_PIPES } from 'ng2-truncate';
@Component({
selector: 'my-component',
template: '<p>{{ "1234 567 89" | words : 2 }}</p>',
pipes: [TRUNCATE_PIPES]
})
export class MyComponent {
}
This will produce the following html
<p>1234 567…</p>
This pipe has also a second parameter to override the suffix used
Check out the Live demo
...Or modify on Plunker here
...Or clone the demo app built using angular-cli: https://github.com/yellowspot/ng2-truncate-demo
To generate all *.js
, *.js.map
and *.d.ts
files:
$ npm run tsc
To lint all *.ts
files:
$ npm run lint
To execute all test via via Karma:
$ npm run test
FAQs
This package has been moved to [@yellowspot/ng-truncate](https://www.npmjs.com/package/@yellowspot/ng-truncate)
The npm package ng2-truncate receives a total of 840 weekly downloads. As such, ng2-truncate popularity was classified as not popular.
We found that ng2-truncate demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.