UIZE/UIZE-JavaScript-Framework — Issue #12: Promote often used utility belt features to root namespace
Author: UIZE
Created: 2011-11-01 05:30:58+00:00
State: open

This is a proposal to promote the following utility belt features, that come in handy quite often, from deeper Uize modules into the root Uize namespace...

- Uize.indexOf, Uize.lastIndexOf
- essentially derived from indexIn, but adapted to also operate on strings and to use built-in indexOf when possible and supported by JavaScript built-in objects (ie. newer versions of JavaScript)
- Uize.indexIn
- adapt to add support for object (ie. which key has specified value)
- adapt to fall back to using built-in indexOf or lastIndexOf Array method, when they are present and when comparison is strict
- adapt to add support for source being a string
- Uize.ensureIn
- checks to see if an element is present, and adds it if not
- supports adding at beginning or adding at end, with optional where parameter
- Uize.extend
- alias of copyInto, for those who are more comfortable with the extend semantic
- Uize.require
- alias to anonymous module with required (to make the simple case of requiring a module deeper in code more convenient & intuitive)
- Uize.isObject
- for consistency with other type checking methods, but also checks for non-null
- Uize.isString
- for consistency with other type checking methods
- Uize.isBoolean
- for consistency with other type checking methods
- Uize.ensureArray
- ensures that the value is an array
- if the value is already an array, then it is simply returned
- if the value is an arguments object, then an array is created from it
- if the value is any other type, then a new array is returned with the value as its single element
- this is useful for methods that want to be versatile and support simple value types in addition to arrays, but want to normalize to array of one element for purpose of implementation code
- Uize.isArrayLike
- checks to see if value is object and has length property, to ensure object can have any Array method called or applied on it (most native implementations only require a basic / minimal Array like interface to work)
- Uize.isNully
- checks to see if a value is null or undefined
- Uize.isEmpty
- checks to see if an object, array, or string is empty, a number is zero, or a Boolean is fals
- promoted from Uize.Data.isEmpty
- Uize.keys
- returns the keys from an object or array
- promoted from Uize.Data.getKeys, shortened for brevity / convenience
- Uize.values
- returns the values from an object or array
- promoted from Uize.Data.getValues, shortened for brevity / convenience
- Uize.totalKeys
- promoted from Uize.Data.getTotalKeys, shortened for brevity / convenience
- Uize.min
- returns minimum value from an array or object
- promoted from Uize.Data.min
- Uize.max
- returns maximum value from an array or object
- promoted from Uize.Data.max
- Uize.emptyOut
- empties out an object or array (most useful for objects)
- promoted from Uize.Data.emptyOut
- Uize.lookup
- promoted from Uize.Data.getLookup, shortened for brevity / convenience
- Uize.reverseLookup
- promoted from Uize.Data.getReverseLookup, shortened for brevity / convenience