Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

words.js

Package Overview
Dependencies
Maintainers
1
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

words.js - npm Package Compare versions

Comparing version 0.2.8 to 0.2.9

tests/jasmine/lib/jasmine-2.0.3/boot.js

2

package.json
{
"name": "words.js",
"version": "0.2.8",
"version": "0.2.9",
"description": "A flexible, robust and powerful Javascript word-string manipulation library.",

@@ -5,0 +5,0 @@ "main": "words.min.js",

words.js
========
Only 5.5Kb minified (depends on strings.js), words.js is a toolbox for words from a space seperated string.
Only 5.7Kb minified (depends on strings.js), words.js is a toolbox for words from a space seperated string.
Great for text input or command-line parsing, educational tools, word-games, text filters, password generators, etc..

@@ -46,3 +46,5 @@ <br/>

__________________________________
words.js depends on, and extends strings.js. Most methods overload strings.js methods, only to focus on words rather than characters.
**words.js depends on, and extends strings.js**, so, for browser use: load strings.js before words.js in your index.html.
Most methods overload strings.js methods, only to focus on words rather than characters.
Where in strings.js you use shuffle to randomly reorder the characters in a string, in words.js the overloaded

@@ -389,2 +391,7 @@ shuffle function randomly reorders the words in a string, or you can shuffle the characters of a specific word in

**0.2.9**
Finaly, the Jasmine tests have arrived. Fixed some minor bugs along the way.
_______________________________
**0.2.7**

@@ -391,0 +398,0 @@

// Generated by CoffeeScript 1.8.0
(function() {
"use strict";
var Str, Strings, Words, applyToValidIndex, changeCase, delimiter, numbersFromArray, stringsFromArray, _,
var Strings, Words, applyToValidIndex, changeCase, delimiter, numbersFromArray, stringsFromArray, _,
__slice = [].slice,

@@ -9,4 +9,10 @@ __hasProp = {}.hasOwnProperty,

Strings = Str = _ = require('strings.js');
if (typeof window !== "undefined" && window !== null) {
Strings = window.Strings;
} else if (typeof module !== "undefined" && module !== null) {
Strings = require('strings.js');
}
_ = Strings;
stringsFromArray = function(array) {

@@ -53,3 +59,3 @@ var strings, value, _i, _len, _ref;

for (index = _j = 0, _ref = this.count - 1; 0 <= _ref ? _j <= _ref : _j >= _ref; index = 0 <= _ref ? ++_j : --_j) {
_results1.push(this.words[index] = Str[method](this.words[index], pos));
_results1.push(this.words[index] = Strings[method](this.words[index], pos));
}

@@ -72,3 +78,3 @@ return _results1;

index = _.positiveIndex(index, this.count);
_results2.push(this.words[index] = Str[method](this.words[index]));
_results2.push(this.words[index] = Strings[method](this.words[index]));
}

@@ -99,9 +105,9 @@ return _results2;

var arg, str, _i, _j, _len, _len1, _ref;
this.words = [];
if (arguments.length < 1) {
return this;
}
this.words = [];
for (_i = 0, _len = arguments.length; _i < _len; _i++) {
arg = arguments[_i];
_ref = Str.split(Str.create(arg), delimiter);
_ref = Strings.split(Strings.create(arg), delimiter);
for (_j = 0, _len1 = _ref.length; _j < _len1; _j++) {

@@ -128,3 +134,3 @@ str = _ref[_j];

}
return Str.trim(string);
return Strings.trim(string);
};

@@ -140,3 +146,3 @@

if (_.notFunction(callback) || this.count < 1) {
return;
return this;
}

@@ -187,3 +193,3 @@ result = [];

this.xs(function(word) {
return Str.reverse(word);
return Strings.reverse(word);
});

@@ -195,3 +201,3 @@ } else if (arguments.length > 0) {

return function(index) {
return _this.words[index] = Str.reverse(_this.words[index]);
return _this.words[index] = Strings.reverse(_this.words[index]);
};

@@ -219,3 +225,3 @@ })(this));

if (word === arg) {
return Str.shuffle(word);
return Strings.shuffle(word);
}

@@ -228,3 +234,3 @@ return true;

this.xs(function(word) {
return Str.shuffle(word);
return Strings.shuffle(word);
});

@@ -236,3 +242,3 @@ } else {

return function(index) {
return _this.words[index] = Str.shuffle(_this.words[index]);
return _this.words[index] = Strings.shuffle(_this.words[index]);
};

@@ -291,3 +297,3 @@ })(this));

var n, _i;
amount = _.forceNumber(amount, 1);
amount = Math.abs(_.forceNumber(amount, 1));
for (n = _i = 1; 1 <= amount ? _i <= amount : _i >= amount; n = 1 <= amount ? ++_i : --_i) {

@@ -304,3 +310,3 @@ this.words.pop();

if ('' !== (arg = _.forceString(arg))) {
this.words.push(Str.trim(arg));
this.words.push(Strings.trim(arg));
}

@@ -321,7 +327,9 @@ }

Words.prototype.prepend = function() {
var arg, count, _i, _len;
for (count = _i = 0, _len = arguments.length; _i < _len; count = ++_i) {
arg = arguments[count];
var arg, pos, _i, _len;
pos = 0;
for (_i = 0, _len = arguments.length; _i < _len; _i++) {
arg = arguments[_i];
if ('' !== (arg = _.forceString(arg))) {
this.words.splice(count, 0, Str.trim(arg));
this.words.splice(pos, 0, Strings.trim(arg));
pos++;
}

@@ -333,9 +341,11 @@ }

Words.prototype.insert = function() {
var count, index, word, words, _i, _len;
var index, pos, word, words, _i, _len;
index = arguments[0], words = 2 <= arguments.length ? __slice.call(arguments, 1) : [];
index = _.positiveIndex(index, this.count);
for (count = _i = 0, _len = words.length; _i < _len; count = ++_i) {
word = words[count];
pos = 0;
for (_i = 0, _len = words.length; _i < _len; _i++) {
word = words[_i];
if ('' !== (word = _.forceString(word))) {
this.words.splice(index + count, 0, Str.trim(word));
this.words.splice(index + pos, 0, Strings.trim(word));
pos++;
}

@@ -350,3 +360,3 @@ }

}
if ('' === (replacement = Str.trim(replacement))) {
if ('' === (replacement = Strings.trim(replacement))) {
return this;

@@ -443,3 +453,3 @@ }

if (module) {
if (typeof module !== "undefined" && module !== null) {
return module.exports = Words;

@@ -446,0 +456,0 @@ }

@@ -1,1 +0,1 @@

(function(){"use strict";var t,r,n,e,o,s,i,u,h,f=[].slice,p={}.hasOwnProperty,c=function(t,r){function n(){this.constructor=t}for(var e in r)p.call(r,e)&&(t[e]=r[e]);return n.prototype=r.prototype,t.prototype=new n,t.__super__=r.prototype,t};return r=t=h=require("strings.js"),u=function(t){var r,n,e,o,s;for(r=[],s=h.forceArray(t),e=0,o=s.length;o>e;e++)n=s[e],h.isString(n)&&r.push(n);return r},i=function(t){var r,n,e,o,s;for(r=[],s=h.forceArray(t),e=0,o=s.length;o>e;e++)n=s[e],h.isNumber(n)&&r.push(n+0);return r},o=function(n,e){var o,s,p,c,l,a,g,d,y,m,w;if(c=u(e),s=i(e),c.length>0&&this.set(r[n].apply(r,[this.string].concat(f.call(c)))),0===s[0]){for(y=[],l=0,g=s.length;g>l;l++)p=s[l],y.push(function(){var r,e,s;for(s=[],o=r=0,e=this.count-1;e>=0?e>=r:r>=e;o=e>=0?++r:--r)s.push(this.words[o]=t[n](this.words[o],p));return s}.call(this));return y}for(e.length<1&&(s=function(){m=[];for(var t=0,r=this.count;r>=0?r>=t:t>=r;r>=0?t++:t--)m.push(t);return m}.apply(this)),w=[],a=0,d=s.length;d>a;a++)o=s[a],o=h.positiveIndex(o,this.count),w.push(this.words[o]=t[n](this.words[o]));return w},e=function(){return function(t,r,n){var e;return!1!==(e=h.positiveIndex(t,r))?n(e):void 0}}(this),s=" ",n=function(r){function n(){this.set.apply(this,arguments)}return c(n,r),n.prototype.set=function(){var r,n,e,o,i,u,h;if(arguments.length<1)return this;for(this.words=[],e=0,i=arguments.length;i>e;e++)for(r=arguments[e],h=t.split(t.create(r),s),o=0,u=h.length;u>o;o++)n=h[o],this.words.push(n);return this},n.prototype.get=function(){var r,n,e,o;if(arguments.length<1)return this.words.join(s);for(n="",e=0,o=arguments.length;o>e;e++)r=arguments[e],r=h.positiveIndex(r,this.count),r!==!1&&(n+=this.words[r]+s);return t.trim(n)},n.prototype.xs=function(t){var r,n,e,o,s,i,u;if(null==t&&(t=function(){return!0}),!(h.notFunction(t)||this.count<1)){for(e=[],u=this.words,r=s=0,i=u.length;i>s;r=++s)o=u[r],(n=t(o,r))&&(n===!0?e.push(o):h.isStringOrNumber(n)&&e.push(n+""));return this.words=e,this}},n.prototype.find=function(t){var r;return r=[],""!==(t=h.forceString(t))&&this.xs(function(n,e){return n===t&&r.push(e+1),!0}),r},n.prototype.upper=function(){return o.call(this,"upper",Array.prototype.slice.call(arguments)),this},n.prototype.lower=function(){return o.call(this,"lower",Array.prototype.slice.call(arguments)),this},n.prototype.reverse=function(){var r,n,o;if(0===(null!=arguments?arguments[0]:void 0))this.xs(function(r){return t.reverse(r)});else if(arguments.length>0)for(n=0,o=arguments.length;o>n;n++)r=arguments[n],e(r,this.count,function(r){return function(n){return r.words[n]=t.reverse(r.words[n])}}(this));else this.xs(function(t){return function(r,n){return t.get(t.count-n)}}(this));return this},n.prototype.shuffle=function(r){var n,o,s,i,u;if(null!=r)if(h.isString(r))for(o=0,i=arguments.length;i>o;o++)n=arguments[o],this.xs(function(){return function(r){return r===n?t.shuffle(r):!0}}(this));else if(0===r)this.xs(function(r){return t.shuffle(r)});else for(s=0,u=arguments.length;u>s;s++)n=arguments[s],e(n,this.count,function(r){return function(n){return r.words[n]=t.shuffle(r.words[n])}}(this));else this.words=h.shuffleArray(this.words);return this},n.prototype.clear=function(){return this.words=[],this},n.prototype.remove=function(){var t,r,e,o,s,i,u;if(arguments.length<1)return this;for(r=[],o=0,i=arguments.length;i>o;o++)t=arguments[o],h.isString(t)?r.unshift(t):h.isNumber(t)&&r.push(n.positiveIndex(t,this.count));for(r=h.noDupAndReverse(h.insertSort(r)),e=s=0,u=r.length;u>s;e=++s)t=r[e],h.isNumber(t)?this.xs(function(){return function(r,n){return n!==t?!0:void 0}}(this)):h.isString(t)&&this.xs(function(r){return r!==t?!0:void 0});return this},n.prototype.pop=function(t){var r,n;for(t=h.forceNumber(t,1),r=n=1;t>=1?t>=n:n>=t;r=t>=1?++n:--n)this.words.pop();return this},n.prototype.push=function(){var r,n,e;for(n=0,e=arguments.length;e>n;n++)r=arguments[n],""!==(r=h.forceString(r))&&this.words.push(t.trim(r));return this},n.prototype.shift=function(t){var r,n;for(t=h.forceNumber(t,1),r=n=1;t>=1?t>=n:n>=t;r=t>=1?++n:--n)this.words.shift();return this},n.prototype.prepend=function(){var r,n,e,o;for(n=e=0,o=arguments.length;o>e;n=++e)r=arguments[n],""!==(r=h.forceString(r))&&this.words.splice(n,0,t.trim(r));return this},n.prototype.insert=function(){var r,n,e,o,s,i;for(n=arguments[0],o=2<=arguments.length?f.call(arguments,1):[],n=h.positiveIndex(n,this.count),r=s=0,i=o.length;i>s;r=++s)e=o[r],""!==(e=h.forceString(e))&&this.words.splice(n+r,0,t.trim(e));return this},n.prototype.replace=function(r,n){return null==n&&(n=""),""===(n=t.trim(n))?this:(h.isNumber(r)?e(r,this.count,function(t){return function(r){return t.words.splice(r,1,n)}}(this)):this.xs(function(t){return t===r?n:!0}),this)},n.prototype.sort=function(){return h.insertSort(this.words),this},n.prototype.startsWith=function(t){var r;return""===(t=h.forceString(t))?!1:(r=!0,t=new n(t),t.xs(function(t){return function(n,e){return n!==t.words[e]?r=!1:void 0}}(this)),r)},n.prototype.endsWith=function(t){var r,e,o,s,i;if(""===(t=h.forceString(t)))return!1;for(o=!0,r=1,t=new n(t),e=s=i=t.count;1>=i?1>=s:s>=1;e=1>=i?++s:--s)t.get(e)!==this.words[this.count-r++]&&(o=!1);return o},n}(r),Object.defineProperty(n.prototype,"$",{get:function(){return this.get()}}),Object.defineProperty(n.prototype,"string",{get:function(){return this.get()}}),Object.defineProperty(n.prototype,"count",{get:function(){return this.words.length}}),n.prototype.unshift=n.prototype.prepend,n.Strings=r,n.Types=r.Types,n.Chars=r.Chars,"undefined"!=typeof window&&null!==window?window.Words=n:module?module.exports=n:void 0}).call(this);
(function(){"use strict";var t,r,n,e,o,i,s,u,h=[].slice,f={}.hasOwnProperty,p=function(t,r){function n(){this.constructor=t}for(var e in r)f.call(r,e)&&(t[e]=r[e]);return n.prototype=r.prototype,t.prototype=new n,t.__super__=r.prototype,t};return"undefined"!=typeof window&&null!==window?t=window.Strings:"undefined"!=typeof module&&null!==module&&(t=require("strings.js")),u=t,s=function(t){var r,n,e,o,i;for(r=[],i=u.forceArray(t),e=0,o=i.length;o>e;e++)n=i[e],u.isString(n)&&r.push(n);return r},i=function(t){var r,n,e,o,i;for(r=[],i=u.forceArray(t),e=0,o=i.length;o>e;e++)n=i[e],u.isNumber(n)&&r.push(n+0);return r},e=function(r,n){var e,o,f,p,c,l,a,g,d,y,m;if(p=s(n),o=i(n),p.length>0&&this.set(t[r].apply(t,[this.string].concat(h.call(p)))),0===o[0]){for(d=[],c=0,a=o.length;a>c;c++)f=o[c],d.push(function(){var n,o,i;for(i=[],e=n=0,o=this.count-1;o>=0?o>=n:n>=o;e=o>=0?++n:--n)i.push(this.words[e]=t[r](this.words[e],f));return i}.call(this));return d}for(n.length<1&&(o=function(){y=[];for(var t=0,r=this.count;r>=0?r>=t:t>=r;r>=0?t++:t--)y.push(t);return y}.apply(this)),m=[],l=0,g=o.length;g>l;l++)e=o[l],e=u.positiveIndex(e,this.count),m.push(this.words[e]=t[r](this.words[e]));return m},n=function(){return function(t,r,n){var e;return!1!==(e=u.positiveIndex(t,r))?n(e):void 0}}(this),o=" ",r=function(r){function i(){this.set.apply(this,arguments)}return p(i,r),i.prototype.set=function(){var r,n,e,i,s,u,h;if(this.words=[],arguments.length<1)return this;for(e=0,s=arguments.length;s>e;e++)for(r=arguments[e],h=t.split(t.create(r),o),i=0,u=h.length;u>i;i++)n=h[i],this.words.push(n);return this},i.prototype.get=function(){var r,n,e,i;if(arguments.length<1)return this.words.join(o);for(n="",e=0,i=arguments.length;i>e;e++)r=arguments[e],r=u.positiveIndex(r,this.count),r!==!1&&(n+=this.words[r]+o);return t.trim(n)},i.prototype.xs=function(t){var r,n,e,o,i,s,h;if(null==t&&(t=function(){return!0}),u.notFunction(t)||this.count<1)return this;for(e=[],h=this.words,r=i=0,s=h.length;s>i;r=++i)o=h[r],(n=t(o,r))&&(n===!0?e.push(o):u.isStringOrNumber(n)&&e.push(n+""));return this.words=e,this},i.prototype.find=function(t){var r;return r=[],""!==(t=u.forceString(t))&&this.xs(function(n,e){return n===t&&r.push(e+1),!0}),r},i.prototype.upper=function(){return e.call(this,"upper",Array.prototype.slice.call(arguments)),this},i.prototype.lower=function(){return e.call(this,"lower",Array.prototype.slice.call(arguments)),this},i.prototype.reverse=function(){var r,e,o;if(0===(null!=arguments?arguments[0]:void 0))this.xs(function(r){return t.reverse(r)});else if(arguments.length>0)for(e=0,o=arguments.length;o>e;e++)r=arguments[e],n(r,this.count,function(r){return function(n){return r.words[n]=t.reverse(r.words[n])}}(this));else this.xs(function(t){return function(r,n){return t.get(t.count-n)}}(this));return this},i.prototype.shuffle=function(r){var e,o,i,s,h;if(null!=r)if(u.isString(r))for(o=0,s=arguments.length;s>o;o++)e=arguments[o],this.xs(function(){return function(r){return r===e?t.shuffle(r):!0}}(this));else if(0===r)this.xs(function(r){return t.shuffle(r)});else for(i=0,h=arguments.length;h>i;i++)e=arguments[i],n(e,this.count,function(r){return function(n){return r.words[n]=t.shuffle(r.words[n])}}(this));else this.words=u.shuffleArray(this.words);return this},i.prototype.clear=function(){return this.words=[],this},i.prototype.remove=function(){var t,r,n,e,o,s,h;if(arguments.length<1)return this;for(r=[],e=0,s=arguments.length;s>e;e++)t=arguments[e],u.isString(t)?r.unshift(t):u.isNumber(t)&&r.push(i.positiveIndex(t,this.count));for(r=u.noDupAndReverse(u.insertSort(r)),n=o=0,h=r.length;h>o;n=++o)t=r[n],u.isNumber(t)?this.xs(function(){return function(r,n){return n!==t?!0:void 0}}(this)):u.isString(t)&&this.xs(function(r){return r!==t?!0:void 0});return this},i.prototype.pop=function(t){var r,n;for(t=Math.abs(u.forceNumber(t,1)),r=n=1;t>=1?t>=n:n>=t;r=t>=1?++n:--n)this.words.pop();return this},i.prototype.push=function(){var r,n,e;for(n=0,e=arguments.length;e>n;n++)r=arguments[n],""!==(r=u.forceString(r))&&this.words.push(t.trim(r));return this},i.prototype.shift=function(t){var r,n;for(t=u.forceNumber(t,1),r=n=1;t>=1?t>=n:n>=t;r=t>=1?++n:--n)this.words.shift();return this},i.prototype.prepend=function(){var r,n,e,o;for(n=0,e=0,o=arguments.length;o>e;e++)r=arguments[e],""!==(r=u.forceString(r))&&(this.words.splice(n,0,t.trim(r)),n++);return this},i.prototype.insert=function(){var r,n,e,o,i,s;for(r=arguments[0],o=2<=arguments.length?h.call(arguments,1):[],r=u.positiveIndex(r,this.count),n=0,i=0,s=o.length;s>i;i++)e=o[i],""!==(e=u.forceString(e))&&(this.words.splice(r+n,0,t.trim(e)),n++);return this},i.prototype.replace=function(r,e){return null==e&&(e=""),""===(e=t.trim(e))?this:(u.isNumber(r)?n(r,this.count,function(t){return function(r){return t.words.splice(r,1,e)}}(this)):this.xs(function(t){return t===r?e:!0}),this)},i.prototype.sort=function(){return u.insertSort(this.words),this},i.prototype.startsWith=function(t){var r;return""===(t=u.forceString(t))?!1:(r=!0,t=new i(t),t.xs(function(t){return function(n,e){return n!==t.words[e]?r=!1:void 0}}(this)),r)},i.prototype.endsWith=function(t){var r,n,e,o,s;if(""===(t=u.forceString(t)))return!1;for(e=!0,r=1,t=new i(t),n=o=s=t.count;1>=s?1>=o:o>=1;n=1>=s?++o:--o)t.get(n)!==this.words[this.count-r++]&&(e=!1);return e},i}(t),Object.defineProperty(r.prototype,"$",{get:function(){return this.get()}}),Object.defineProperty(r.prototype,"string",{get:function(){return this.get()}}),Object.defineProperty(r.prototype,"count",{get:function(){return this.words.length}}),r.prototype.unshift=r.prototype.prepend,r.Strings=t,r.Types=t.Types,r.Chars=t.Chars,"undefined"!=typeof window&&null!==window?window.Words=r:"undefined"!=typeof module&&null!==module?module.exports=r:void 0}).call(this);

Sorry, the diff of this file is not supported yet

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